Hello world,
I am running Grafana 9.2.0 on Ubuntu 18.04 LTS and mysql as database.
Visualizing data over time imported from my central heating system works fine.
Now I want to create an bar chart which shows me the kWh consumption per month.
The column time is of datetime type.
This is the SQL select which should be transferred:
mysql> SELECT year(time),month(time),sum(anfbren/100*25)/60 AS “kWh” FROM data group by year(time),month(time);
±-----------±------------±--------------+
| year(time) | month(time) | kWh |
±-----------±------------±--------------+
| 2020 | 10 | 999.13333333 |
…
| 2023 | 1 | 819.30000000 |
±-----------±------------±--------------+
I’ve created a bar chart and get the error, that Bar charts requires a string or time field. Next step was to concat year and month:
SELECT convert(concat_ws(‘’,year(time),month(time)),CHAR) as month,sum(anfbren/100*25)/60 AS “kWh” FROM data group by month;
±-------±--------------+
| monat | kWh |
±-------±--------------+
| 202010 | 999.13333333 |
…
| 20231 | 819.30000000 |
±-------±--------------+
Currently I don’t get the dots connected, how to match group by and time fields and / or generating a string.
Any help appreciated.
B.