Re: Average New Users Per DOW - Mailing list pgsql-general

From Robert DiFalco
Subject Re: Average New Users Per DOW
Date
Msg-id CAAXGW-wc2sDxrxYLjPd_Bsf=AbTYOTNO4g-44ufp6L1s-YN33g@mail.gmail.com
Whole thread Raw
In response to Re: Average New Users Per DOW  (Paul Jungwirth <pj@illuminatedcomputing.com>)
Responses Re: Average New Users Per DOW
Re: Average New Users Per DOW
List pgsql-general
Thanks Paul, I guess I'm not sure how a generate_series between 0 to 6 would solve this problem. Wouldn't I have to generate a series based on the date range (by day) and then group by DOW _after_ that? Can you give me an example of how I'd do it with a series based on 0 to 6?

On Mon, Jul 6, 2015 at 10:58 AM, Paul Jungwirth <pj@illuminatedcomputing.com> wrote:
> I'm not sure how to create a result where I get the average number of
> new users per day of the week. My issues are that days that did not
> have any new users will not be factored into the average

This is a pretty common problem with time-series queries when there is sparse data. My go-to solution is to use generate_series---in your case from 0 to 6---then do a left join from there to your actual data.

Paul





--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

pgsql-general by date:

Previous
From: Paul Jungwirth
Date:
Subject: Re: Average New Users Per DOW
Next
From: "David G. Johnston"
Date:
Subject: Re: Average New Users Per DOW