Re: Problems with UNION ALL and ORDER BY

Поиск
Список
Период
Сортировка
От Gaetano Mendola
Тема Re: Problems with UNION ALL and ORDER BY
Дата
Msg-id 410E6FBE.9000103@bigfoot.com
обсуждение исходный текст
Ответ на Problems with UNION ALL and ORDER BY  (Kaloyan Iliev Iliev <news1@faith.digsys.bg>)
Список pgsql-sql
Kaloyan Iliev Iliev wrote:
> 
> Dear friends...,
> I have the following problem:
> 
> 
> select  .....  from  ....  where  ....
> UNION ALL
> 
> select ...  from  ....  where  ....
> ORDER BY field1
> 
> But the the order by doesn't work properly. It returns the rows of the 
> first query ordered and then appends the rows of the second query 
> ordered. But this is not what i expect. I expect the result of both 
> queries to be orderd. So I try.
> 
> SELECT TEMP.*
> FROM
> (
> select ..... from  ....  where  ....
> UNION ALL
> 
> select ...  from  ....  where ....
> ) TEMP
> ORDER BY TEMP.field1
> 
> But this also doesn't work. Any ideas.p

This have to work. Could you please provide a real example ( creation table,
insertion data and query execution ).


Regards
Gaetano Mendola




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

Предыдущее
От: Kaloyan Iliev Iliev
Дата:
Сообщение: Re: Problems with UNION ALL and ORDER BY
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Problems with UNION ALL and ORDER BY