Skip to content
Advertisement

Group by days of a month in CockroachDB

In CockroachDB, I want to have such this query on a specific month for its every day:

the problem is that I want it on my local date. What should I do? My goal is:

“month, day, count, sum” as result columns for a month.


UPDATE:

I have found a suitable query for this purpose:

Thanks to @histocrat for easier answer 🙂 by replacing

by this:

Advertisement

Answer

To group results by both month and day, you can use the date_part function.

Depending on what type created_at is, you may need to cast or convert it first (for example, group by date_part('month', created_at::timestamptz)).

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