From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Gauthier <davegauthierpg@gmail.com>
Cc: Postgres General <pgsql-general@postgresql.org>
Subject: Re: getting daily stats for event counts
Date: Tue, 23 Jun 2020 12:28:30 -0400
Message-ID: <2153718.1592929710@sss.pgh.pa.us> (raw)
In-Reply-To: <CAMBRECA2_ahWXbCDxynPob7cvyjOXVPQC7aqCgscq=tXiD9B1g@mail.gmail.com>
References: <CAMBRECA2_ahWXbCDxynPob7cvyjOXVPQC7aqCgscq=tXiD9B1g@mail.gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, davegauthierpg@gmail.com
Subject: Re: getting daily stats for event counts
In-Reply-To: <2153718.1592929710@sss.pgh.pa.us>
References: <CAMBRECA2_ahWXbCDxynPob7cvyjOXVPQC7aqCgscq=tXiD9B1g@mail.gmail.com> <2153718.1592929710@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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