pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Edward Macnaghten <eddy@edlsystems.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Recursive Queries
Date: Thu, 16 Apr 2020 14:36:38 +0100
Message-ID: <d2bc6809-520d-5525-c264-a123cb9aa57e@edlsystems.com> (raw)
In-Reply-To: <CA+cR4zeUtkNWMx_PBRyOv+Qg_Pxt6sbJbwKv78tGetCoPVBTbw@mail.gmail.com>
References: <CA+cR4zeUtkNWMx_PBRyOv+Qg_Pxt6sbJbwKv78tGetCoPVBTbw@mail.gmail.com>

On 16/04/2020 09:35, Alex Magnum wrote:
> Hi,
> I have a simple table with singupĀ timestamps
>
> What I would like to do is to create a table as shown below that
> displays the counts per our for the past n dates.

Various ways, but for me...

SELECT hour, SUM(CASE(WHEN date = date THEN 1 ELSE 0)), ...., ....
WHERE whatever
GROUP BY hour

could be your friend







view thread (27+ messages)  latest in thread

Message-ID: <d2bc6809-520d-5525-c264-a123cb9aa57e@edlsystems.com>
Permalink:  ../d2bc6809-520d-5525-c264-a123cb9aa57e@edlsystems.com/
Also on:    postgresql.org/message-id/d2bc6809-520d-5525-c264-a123cb9aa57e@edlsystems.com

 · 

reply

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: eddy@edlsystems.com
  Subject: Re: Recursive Queries
  In-Reply-To: <d2bc6809-520d-5525-c264-a123cb9aa57e@edlsystems.com>
  References: <CA+cR4zeUtkNWMx_PBRyOv+Qg_Pxt6sbJbwKv78tGetCoPVBTbw@mail.gmail.com> <d2bc6809-520d-5525-c264-a123cb9aa57e@edlsystems.com>

* 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