How can I aggregate metrics per day in a Grafana graph with DataSource PostgreSQL?

Hi there. I am new to Grafana. I’m using time series Graph with DataSource PostgreSQL.
I’m able to show the basic graph now.

I’d like to aggregate metrics per day in graph like the belowing picture, is there any way?
My PostgreSQL is as below. It works fine in PostgreSQL DB. But it reports error “Found no column named time” in Grafana graph.

SELECT to_char(dateColumn, ‘YYYY-MM-DD’) AS time,
count(id) AS total_count,
max(id) AS total_amount
FROM mytable
WHERE dateColumn BETWEEN ‘2018-03-30’ AND current_date
GROUP BY time
ORDER BY time

grafana02

Anyone can help?

Hi, I guess you found a way to solve your problem since june, but if not, have you tried something like :

SELECT
$__time(dateColumn::date),