Re: Use of GROUP BY

Поиск
Список
Период
Сортировка
От Oleg Lebedev
Тема Re: Use of GROUP BY
Дата
Msg-id 993DBE5B4D02194382EC8DF8554A5273016DB5@postoffice.waterford.org
обсуждение исходный текст
Ответ на Use of GROUP BY  ("Mihai Gheorghiu" <tanethq@earthlink.net>)
Список pgsql-general
Only attribute in SELECT-clause that are not used in aggregation must be
included in GROUP BY clause. So, if you had smth like:
select field1, sum(amount) from table1 where field1 = 1234 GROUP BY
field1;
You would have to include GROUP BY field 1 as shown above.
In your case, it would just sum up all the amount values in your table.

-----Original Message-----
From: Mihai Gheorghiu [mailto:tanethq@earthlink.net]
Sent: Wednesday, October 02, 2002 2:42 PM
To: pgsql-general@postgresql.org
Subject: [GENERAL] Use of GROUP BY


PG7.2.1 on RH7.3
There is no 1234 value in field1.
select sum(amount) from table1 where field1 = 1234;
 sum
-----

(1 row)

select sum(amount) from table1 where field1 = 1234 group by field1;  sum
-----
(0 rows)

If GROUP BY should always be used in statements using aggregate
functions, why don't I get an error?

Thank you all.


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

В списке pgsql-general по дате отправления:

Предыдущее
От: "Mihai Gheorghiu"
Дата:
Сообщение: Use of GROUP BY
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: Oracle SGA like feature???