Re: SQL error - please help.

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: SQL error - please help.
Дата
Msg-id 20050822072134.S87514@megazone.bigpanda.com
обсуждение исходный текст
Ответ на SQL error - please help.  (Bernard <bht@actrix.gen.nz>)
Список pgsql-general
On Tue, 23 Aug 2005, Bernard wrote:

> Dear Postgresql specialists
>
> I would like to seek help with a SQL query that was developed and
> tested with other SQL92 compliant databases.

IIRC, allowing select items that are not in the group by but are
functionally dependant on the group by columns was added in SQL99.

7.9 <query specification> (in the SQL92 draft) states "If T is a grouped
table, then each <column reference> in each <value expression> that
references a column of T shall reference a grouping column or be specified
within a <set function specification>" which is not the case in the query
below.

There's been talk about doing the SQL99 rules in the past, but noone's
stepped up to do it.

> SELECT
>  DEPARTMENT.PK,
> DEPARTMENT.NAME,
> MIN(PROJECT.VALUE)AS RATING
>  FROM DEPARTMENT,
> PROJECT
>  WHERE DEPARTMENT.PK=PROJECT.DEPARTMENT_FK
>   GROUP BY DEPARTMENT.PK
>  ORDER BY DEPARTMENT.PK;
>
> ERROR:  column "department.name" must appear in the GROUP BY clause or
> be used in an aggregate function

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

Предыдущее
От: "A. Kretschmer"
Дата:
Сообщение: Re:
Следующее
От: Tom Lane
Дата:
Сообщение: Re: http://www.postgresql.org/docs/8.0/static/xfunc-sql.html