pg.ddx.io pgsql-general@postgresql.org mailing list archivehelp / color / mirror / Atom feed
getting daily stats for event counts 2+ messages / 2 participants [nested] [flat]
* getting daily stats for event counts @ 2020-06-23 16:04 David Gauthier <davegauthierpg@gmail.com> 0 siblings, 1 reply; 2+ messages in thread From: David Gauthier @ 2020-06-23 16:04 UTC (permalink / raw) To: pgsql-general Hi: 9.6.0 on linux 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 ? ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: getting daily stats for event counts @ 2020-06-23 16:28 Tom Lane <tgl@sss.pgh.pa.us> parent: David Gauthier <davegauthierpg@gmail.com> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2020-06-23 16:28 UTC (permalink / raw) To: David Gauthier <davegauthierpg@gmail.com>; +Cc: pgsql-general David Gauthier <davegauthierpg@gmail.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 ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2020-06-23 16:28 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2020-06-23 16:04 getting daily stats for event counts David Gauthier <davegauthierpg@gmail.com> 2020-06-23 16:28 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox