Re: [SQL] Question about SELECT and ORDER BY

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [SQL] Question about SELECT and ORDER BY
Дата
Msg-id 28465.949599989@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Question about SELECT and ORDER BY  ("Vladimir Terziev" <vlady@school.digsys.bg>)
Список pgsql-sql
"Vladimir Terziev" <vlady@school.digsys.bg> writes:
> I have a query:
>    SELECT table1.attr1 AS ALIAS, attr2 from table1 UNION ALL
>    SELECT table2.attr1, attr3 from table2 ORDER BY ALIAS;

> I want to have a result from ORDER BY length(ALIAS), but this is imposible.

SELECT ... UNION ... ORDER BY is pretty broken in current sources;
in particular adding a hidden column to sort on doesn't work when
there's a UNION.  I've looked a little bit at fixing this, and it
looks like it will take the long-threatened querytree restructuring
to deal with it in any sensible fashion.  Maybe that'll happen for 7.1.

In the meantime use Mark Volpe's workaround of only sorting on
columns that are in the select list.
        regards, tom lane


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

Предыдущее
От: "David Warren"
Дата:
Сообщение: sql statements
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [SQL] sql statements