Re: ORDER BY in UNION query

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: ORDER BY in UNION query
Дата
Msg-id 41E27BF2.8080701@archonet.com
обсуждение исходный текст
Ответ на ORDER BY in UNION query  (Antony Paul <antonypaul24@gmail.com>)
Ответы Re: ORDER BY in UNION query  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Antony Paul wrote:
> Hi,
>     I need to use ORDER BY clause in a UNION query and the Order BY
> columns are not included in the SELECT statement. I tried like this
>
> (select .... from a) UNION (select ..... from b) order by a.ename;
>
> It says that
> ERROR:  Attribute "ename" not found
>
> How to do this.

The "order by" is applying to the results of the union, not one of the
sub-selects. If you want to sort by a value, you'll need to include it
in the results list.

--
   Richard Huxton
   Archonet Ltd

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

Предыдущее
От: Mark Rae
Дата:
Сообщение: Re: PostgreSQL 8.0.0 Release Candidate 4
Следующее
От: John Sidney-Woollett
Дата:
Сообщение: Re: ORDER BY in UNION query