Thread: group by date_part

group by date_part

From
M.Mazurek@poznan.multinet.pl
Date:
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

From
Tom Lane
Date:
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


Re: [SQL] group by date_part

From
M.Mazurek@poznan.multinet.pl
Date:
On Sun, 20 Feb 2000, Tom Lane wrote:
> select date_part('dow',data::datetime), count(*) from stats
>     group by date_part('dow',data::datetime);

thx, i think i got the idea:)

mazek