group by date_part
group by date_part
От:
M.Mazurek@poznan.multinet.pl
Дата:
HI,
I have a table with some statistics and datetime field (data). I want
select counted records by day of the week.
select count (*) from stats group by date_part('dow',data::datetime_;
I get everthing sortded just as I wanted to, but how can I ad another
column to know which dow it is?
eg:
dow|count
---------
0 |123
4 | 322
...
mazek
Re: [SQL] group by date_part
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
M.Mazurek@poznan.multinet.pl writes:
> select count (*) from stats group by date_part('dow',data::datetime_;
> I get everthing sortded just as I wanted to, but how can I ad another
> column to know which dow it is?
select date_part('dow',data::datetime), count(*) from statsgroup by date_part('dow',data::datetime);
regards, tom lane