7.3 "group by" issue

Поиск
Список
Период
Сортировка
От Dan Langille
Тема 7.3 "group by" issue
Дата
Msg-id 3E56231A.22301.1E69F0EA@localhost
обсуждение исходный текст
Список pgsql-sql
Hi folks,

This query:

SELECT element_id as wle_element_id, COUNT(watch_list_id)   FROM watch_list JOIN watch_list_element       ON
watch_list.id     = watch_list_element.watch_list_id      AND watch_list.user_id = 1 GROUP BY
watch_list_element.element_id

gives this error:

ERROR:  Attribute unnamed_join.element_id must be GROUPed or used in 
an aggregate function

Note that in the select the table name is not mentioned but it is in 
the GROUP BY.  To solve the problem, you either have to name the 
table in both locations or not name it in either location.

Why?

-- 
Dan Langille : http://www.langille.org/



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

Предыдущее
От: Rafal Kedziorski
Дата:
Сообщение: Re: good style?
Следующее
От: "Gaetano Mendola"
Дата:
Сообщение: Re: 7.3 "group by" issue