select count(*) from hits group by count;

Поиск
Список
Период
Сортировка
От Oleg Bartunov
Тема select count(*) from hits group by count;
Дата
Msg-id Pine.GSO.3.96.SK.1000129123357.18405o-100000@ra
обсуждение исходный текст
Ответы Re: [HACKERS] select count(*) from hits group by count;  (Tom Lane <tgl@sss.pgh.pa.us>)
RE: [HACKERS] select count(*) from hits group by count;  (Dmitry Samersoff <dms@wplus.net>)
Список 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 по дате отправления:

Предыдущее
От: Ed Loehr
Дата:
Сообщение: Re: [HACKERS] Help with pl/pgsql, triggers, and foreign keys
Следующее
От: Michael Meskes
Дата:
Сообщение: Re: [HACKERS] Copyright