Group by Time MariaDB

Hello, i have been working with grafana since 2 days and I’m wondering if you can help we with configuration my dashboard.

I’m tracking my current consumption of my appartment via iobroker into a MariaDB. I have access via grafana to my DB but I do not know how i can group the collected data per day.

Welcome to the forum.

I do not use the query builder as you have done. If you switch to code (on the far right), you should be able to enter your SQL query that includes the GROUP BY statement. For example:

SELECT count(*), record_date FROM anytable WHERE anytable.anycolumn = 'anycondition' GROUP BY YEAR(record_date), month(record_date);

where record_date is a date type TIMESTAMP.

1 Like

Like this

SELECT ts, val FROM ts_number WHERE id = 16 GROUP BY month(ts), month(val) ?

You can’t “group by month()” on a value which is not a timestamp.

month() is a function which takes a date/time value and returns the month part
of the date. For any other type of input it makes no sense.

Antony.