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

From David G. Johnston
Subject Re: Average New Users Per DOW
Date
Msg-id CAKFQuwa9N1-ciQw+Yao=-ZCiUpaoJYT=w-0b-++2XdD92qx47Q@mail.gmail.com
Whole thread Raw
In response to Re: Average New Users Per DOW  (Robert DiFalco <robert.difalco@gmail.com>)
List pgsql-general
On Mon, Jul 6, 2015 at 2:04 PM, Robert DiFalco <robert.difalco@gmail.com> wrote:
Wouldn't I have to generate a series based on the date range (by day) and then group by DOW _after_ that? 

​You are correct.​

WITH userdays (dow, user_count) AS ( existing_query, more or less )
​, day_counts (dow, count_of_days) AS ( SELECT generate_series(user_earliest_created_date, user_most_recent_created_date) )​
SELECT dow, coalesce(user_count, 0) / count_of_days
FROM day_counts
LEFT JOIN userdays USING (dow)
​;​

David J.
 

pgsql-general by date:

Previous
From: Robert DiFalco
Date:
Subject: Re: Average New Users Per DOW
Next
From: Paul Jungwirth
Date:
Subject: Re: Average New Users Per DOW