Re: Group by date - Mailing list pgsql-general

From missive@frontiernet.net (Lee Harr)
Subject Re: Group by date
Date
Msg-id 9m1kdr$peg$1@node21.cwnet.roc.gblx.net
Whole thread Raw
List pgsql-general
On 21 Aug 2001 23:10:08 -0700, Dale Emmons <dale@emmons.com> wrote:
> Hello!
>
> I'm trying to be a convert from mysql, which I feel quite comfortable with.
>
> In mysql I can do the following:
>
> CREATE TEMP TABLE hits (
>      datetime TIMESTAMP
> );
>
> Fill it with some data, and then do this:
>
> SELECT datetime, COUNT(*)
> FROM hits
> GROUP BY DATE(datetime)
>
> When I try that in PostgreSQL I get this error when I try the above query:
> Attribute hits.datetime must be GROUPed or used in an aggregate function
>
> The query works fine in mysql, why not postgres?
>


Try this:

SELECT DATE(datetime), count(*)
FROM hits
GROUP BY DATE(datetime);




pgsql-general by date:

Previous
From: Jan Wieck
Date:
Subject: Re: SELECT FOR UPDATE
Next
From: missive@frontiernet.net (Lee Harr)
Date:
Subject: Re: Group by date