Skip to content
Advertisement

PostgreSQL – Find number of installs each day given a table of installs and uninstalls

I have a table for machine installations in this way:

I need a query that returns the number of installed machines per day. Like this:

I know that given a date, say ‘2020-01-03’, I can get the number of installed machines as follows:

However, I do not know how to query in such a way I can get the result for all dates at one query.

Advertisement

Answer

Using generated series from 2020-01-01 to 2020-01-15. Adjust ‘<= / >’ as needed.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement