Re: Problems with UNION ALL and ORDER BY - Mailing list pgsql-sql

From Tom Lane
Subject Re: Problems with UNION ALL and ORDER BY
Date
Msg-id 10984.1091464511@sss.pgh.pa.us
Whole thread Raw
In response to Problems with UNION ALL and ORDER BY  (Kaloyan Iliev Iliev <news1@faith.digsys.bg>)
Responses Re: Problems with UNION ALL and ORDER BY  (Kaloyan Iliev Iliev <news1@faith.digsys.bg>)
List pgsql-sql
Kaloyan Iliev Iliev <news1@faith.digsys.bg> writes:
>  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.

Pray tell, what Postgres release are you using?

AFAICT this will result in an overall sort in all PG releases since 7.0.
I don't have anything older to test...
        regards, tom lane


pgsql-sql by date:

Previous
From: Kaloyan Iliev Iliev
Date:
Subject: Problems with UNION ALL and ORDER BY
Next
From: Kaloyan Iliev Iliev
Date:
Subject: Re: Problems with UNION ALL and ORDER BY