| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | David Gauthier <davegauthierpg(at)gmail(dot)com> |
| Cc: | Postgres General <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: getting daily stats for event counts |
| Date: | 2020-06-23 16:28:30 |
| Message-ID: | 2153718.1592929710@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
David Gauthier <davegauthierpg(at)gmail(dot)com> writes:
> I have a table which logs the inception of an event with an
> "incept_datetime" (timestamptz) field. I want to know how many events
> occurred per day from one date to the next using midnight as a marker for
> each day reported. The end result should be something like...
> 2019-06-23 44
> 2019-06-24 18
> 2019-06-25 38
> etc...
> Is there a query that can do this ?
Something involving GROUP BY date_trunc('day', incept_datetime)
ought to do it, possibly with some fooling around required
depending on what definition of "midnight" you want to use.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Thomas Kellerer | 2020-06-23 16:39:37 | Dependencies of Matviews? |
| Previous Message | David Gauthier | 2020-06-23 16:04:50 | getting daily stats for event counts |