select count(*) from hits group by count; - Mailing list pgsql-hackers

From Oleg Bartunov
Subject select count(*) from hits group by count;
Date
Msg-id Pine.GSO.3.96.SK.1000129123357.18405o-100000@ra
Whole thread Raw
Responses Re: [HACKERS] select count(*) from hits group by count;
RE: [HACKERS] select count(*) from hits group by count;
List pgsql-hackers
Hi there,

I have a table hits:
discovery=> \d hits
Table    = hits
+----------------------------------+----------------------------------+-------+
|              Field               |              Type                | Length|
+----------------------------------+----------------------------------+-------+
| msg_id                           | int4 not null                    |     4 |
| count                            | int4 not null                    |     4 |
| first_access                     | datetime default now ( )         |     8 |
| last_access                      | datetime                         |     8 |
+----------------------------------+----------------------------------+-------+
Index:    hits_pkey

and query:
discovery=> select count(*)  from hits group by count;                         
ERROR:  Aggregates not allowed in GROUP BY clause

There's easy workaround :
discovery=> select count(*) as qq  from hits group by count;
but I'm curious is this a valid query ?
Last snapshot also behave like 6.5.3


Another question:
discovery=> select count(*) as qqq,* from hits group by last_access;
produces error:
ERROR:  Illegal use of aggregates or non-group column in target list

Do I really need to have all fields in GROUP clause ?
Mysql seems allows this ?
Regards,
    Oleg

_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83



pgsql-hackers by date:

Previous
From: Ed Loehr
Date:
Subject: Re: [HACKERS] Help with pl/pgsql, triggers, and foreign keys
Next
From: Michael Meskes
Date:
Subject: Re: [HACKERS] Copyright