Re: [SQL] counts of groupings by date year-month

2009-02-27 Thread Andreas Kretschmer
Carol Cheung wrote: > Hi, > I have a table called temp > > access_date | active | status > -++ > 2009-02-01 | t | 15 > 2009-02-01 | f | 16 > 2009-02-02 | f | 17 > 2009-02-01 | t | 17 > 2009-02-02 | f | 21 > 2009-

Re: [SQL] counts of groupings by date year-month

2009-02-27 Thread Tom Lane
Carol Cheung writes: > I tried something like > SELECT to_char(access_date, 'MM') as year_month, count(year_month) > FROM temp GROUP BY year_month ORDER BY year_month; The only problem in what you wrote was the illegal cross-reference from one output column to another. Just use count(*) ins

Re: [SQL] counts of groupings by date year-month

2009-02-27 Thread Scott Marlowe
On Fri, Feb 27, 2009 at 2:02 PM, Carol Cheung wrote: > Hi, > I have a table called temp > >  access_date | active | status > -++ >  2009-02-01  | t      |     15 >  2009-02-01  | f      |     16 >  2009-02-02  | f      |     17 >  2009-02-01  | t      |     17 >  2009-0

[SQL] counts of groupings by date year-month

2009-02-27 Thread Carol Cheung
Hi, I have a table called temp access_date | active | status -++ 2009-02-01 | t | 15 2009-02-01 | f | 16 2009-02-02 | f | 17 2009-02-01 | t | 17 2009-02-02 | f | 21 2009-01-01 | t | 20 2009-01-01 | t