X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B6E0AD1B18A for ; Mon, 2 Aug 2004 13:36:39 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 02700-08 for ; Mon, 2 Aug 2004 16:36:36 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 236B9D1B171 for ; Mon, 2 Aug 2004 13:36:34 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i72GZBEJ010985; Mon, 2 Aug 2004 12:35:12 -0400 (EDT) To: Kaloyan Iliev Iliev Cc: pgsql-sql@postgresql.org Subject: Re: Problems with UNION ALL and ORDER BY In-reply-to: <410E6376.1010404@faith.digsys.bg> References: <410E6376.1010404@faith.digsys.bg> Comments: In-reply-to Kaloyan Iliev Iliev message dated "Mon, 02 Aug 2004 18:53:26 +0300" Date: Mon, 02 Aug 2004 12:35:11 -0400 Message-ID: <10984.1091464511@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/9 X-Sequence-Number: 18506 Kaloyan Iliev Iliev 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