| From: | Michael Glaesemann <grzm(at)seespotcode(dot)net> |
|---|---|
| To: | brian <brian(at)zijn-digital(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: monthly tally of new memberships |
| Date: | 2007-07-18 18:47:30 |
| Message-ID: | 92B3E197-2E45-420D-A847-E25F7981AF7C@seespotcode.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Jul 18, 2007, at 13:29 , brian wrote:
> This returns the new memberships for each day, ignoring days
> without any. What i'd like to do though, is to select only the 1st
> of each month, summing the new memberships or that month, eg:
>
> month | applications
> 2006-05-01 | 57
> 2006-06-01 | 36
> 2006-07-01 | 72
Try something like this:
SELECT date_trunc('month', applied)::date AS date_applied
, count(id) AS applications
FROM member
GROUP BY applied
ORDER BY date_applied ASC;
Note I remove the WHERE applied = applied, as this is just identity.
Michael Glaesemann
grzm seespotcode net
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jim C. Nasby | 2007-07-18 18:50:07 | Re: [PERFORM] Parrallel query execution for UNION ALL Queries |
| Previous Message | Peter Eisentraut | 2007-07-18 18:46:45 | Re: it works, but is it legal to separate schema/table/field references using spaces |