Sum of max value per Month

Hi Community!

Can anybody help me with MYSQL.
(Grafana 9.2.6)

I have a bar with kWh/Day.
These are the max values of the day from MYSQL.
Now I wont the sum of these values per month.

Bildschirmfoto vom 2022-12-02 08-22-20

Here is the code:

SELECT 
DATE_FORMAT(time, '%Y-%m-%d') AS DAY,
  max(value) AS "KWH_pro_Tag"
  FROM Item125
GROUP BY DATE_FORMAT(time, '%Y-%m-%d')
ORDER BY DAY DESC

Welcome

So your issue is not really grafana but mysql. That said change date formats to
%Y-%m

Hi, when I change this,
I only get the max value of a day in the month not
the sum of this values.

Again you might be better of posting on a mysql forum

Select sum(KWH_pro_Tag),
DATE_FORMAT(DAY, '%Y-%m) as DAY
 from
(
SELECT 
DATE_FORMAT(time, '%Y-%m-%d') AS DAY,
  max(value) AS "KWH_pro_Tag"
  FROM Item125
GROUP BY DATE_FORMAT(time, '%Y-%m-%d')
) mx
GROUP BY DATE_FORMAT(DAY, '%Y-%m')
ORDER BY DAY DESC

Something like this maybe?

Yes :slight_smile: :slight_smile: you are a genius!!