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 1F997D1B1B4 for ; Mon, 2 Aug 2004 13:43:34 -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 07143-04 for ; Mon, 2 Aug 2004 16:43:28 +0000 (GMT) Received: from school.digsys.bg (school.digsys.bg [193.68.6.1]) by svr1.postgresql.org (Postfix) with ESMTP id 9799FD1B1DC for ; Mon, 2 Aug 2004 13:43:25 -0300 (ADT) Received: from faith.digsys.bg (root@www1.digsys.bg [193.68.6.128]) by school.digsys.bg (8.11.6/8.10.1) with ESMTP id i72GhGE22696; Mon, 2 Aug 2004 19:43:17 +0300 (EEST) Message-ID: <410E6E42.6030206@faith.digsys.bg> Date: Mon, 02 Aug 2004 19:39:30 +0300 From: Kaloyan Iliev Iliev User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040115 X-Accept-Language: en-us, en, bg MIME-Version: 1.0 To: Tom Lane Cc: pgsql-sql@postgresql.org Subject: Re: Problems with UNION ALL and ORDER BY References: <410E6376.1010404@faith.digsys.bg> <10984.1091464511@sss.pgh.pa.us> In-Reply-To: <10984.1091464511@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=SEE_FOR_YOURSELF X-Spam-Level: X-Archive-Number: 200408/10 X-Sequence-Number: 18507 Dear Tom, As I say in my previous letter I am using 7.2.3. If you wish I can show you the query and the result to see for yourself, that there is something wrong. It just don't order the overall result but the separate results of the both subqueries. Tom Lane wrote: >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 > > > >