Re: Problems with UNION ALL and ORDER BY

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kaloyan Iliev Iliev <news1(at)faith(dot)digsys(dot)bg>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Problems with UNION ALL and ORDER BY
Date: 2004-08-02 16:35:11
Message-ID: 10984.1091464511@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Kaloyan Iliev Iliev <news1(at)faith(dot)digsys(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Kaloyan Iliev Iliev 2004-08-02 16:39:30 Re: Problems with UNION ALL and ORDER BY
Previous Message Kaloyan Iliev Iliev 2004-08-02 16:09:04 Problems with UNION ALL and ORDER BY