select count(*) from hits group by count;

From: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: select count(*) from hits group by count;
Date: 2000-01-29 09:39:42
Message-ID: Pine.GSO.3.96.SK.1000129123357.18405o-100000@ra
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)sai(dot)msu(dot)su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Meskes 2000-01-29 09:42:17 Re: [HACKERS] Copyright
Previous Message Michael Meskes 2000-01-29 09:36:55 Re: [HACKERS] Copyright