Create Panel with historic count

Hello Grafana Community!

I would like to create a Grafana panel with our user database (PostgreSQL). This scene from HBO’s Silicon Valley already describes it perfectly.

But I can’t figure out how to get the “historical count” working.

My rough idea is this:

SELECT
    created as time,
    count(*)
FROM
    user
WHERE 
    created BETWEEN "FIXED START DATE" AND created
ORDER BY 
    created
ASC

But I encounter issues, that I have to add a GROUP BY clause, because of the aggregate function. Which seems legitimate. But how can I do an aggregation with the “history” of existing entities to the time of the graph position?

I would be thankful for every assistant advice!

Probably cumulative sum is your keyword. You just need to find/develop SQL (PosgreSQL) implementation. Some tips: https://stackoverflow.com/questions/22841206/calculating-cumulative-sum-in-postgresql

1 Like

Wow, your awesome! With your reference on the stackoverflow link, I found another helpful answer which exactly reproduced my issue and needs.

Thanks for letting me start the week so happy! Have a great day!