Skip to content
Advertisement

How to view hourly results during the time specified in Postgres

I want to create a query that returns a list of timezones as a result when the following conditions are specified.

How can I get this?

Advertisement

Answer

Use generate_series to create the records from the time interval, and jsonb_build_objebt with jsonb_agg to create your json document:

Demo: db<>fiddle

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