Re: Group by date
Re: Group by date
От:
missive@frontiernet.net (Lee Harr)
Дата:
On 21 Aug 2001 23:10:08 -0700, Dale Emmons 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);