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 526868BA04D for ; Fri, 18 Feb 2005 08:25:22 +0000 (GMT) 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 22267-03 for ; Fri, 18 Feb 2005 08:25:19 +0000 (GMT) Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.250.190.2]) by svr1.postgresql.org (Postfix) with ESMTP id B55A88B9F8B for ; Fri, 18 Feb 2005 08:25:20 +0000 (GMT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id CDD8C31E34; Fri, 18 Feb 2005 09:25:19 +0100 (MET) From: CoL X-Newsgroups: pgsql.sql Subject: Re: VIEW / ORDER BY + UNION Date: Fri, 18 Feb 2005 09:26:26 +0100 Organization: Hub.Org Networking Services Lines: 24 Message-ID: References: Reply-To: col@mportal.hu Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8a6) Gecko/20050111 X-Accept-Language: en-us, en In-Reply-To: To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.103 tagged_above=0 required=5 tests=AWL, UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200502/260 X-Sequence-Number: 20371 hi, WeiShang wrote, On 2/17/2005 16:46: > Hi, I have created a view like this : > > CREATE VIEW v1 AS (SELECT orderno,weekday,time FROM t1,t2 where > t1.orderno=t2.orderno); > > if I create a SQL statment: > > (SELECT orderno FROM v1 WHERE weekday='MON' ORDER BY orderno) > UNION > (SELECT orderno FROM v1 WHERE weekday='WED' ORDER BY orderno) > UNION > (SELECT orderno FROM v1 WHERE weekday='FRI' ORDER BY orderno); > > Will the whole result will be sorted by the field orderno? nothing says it will. you havet to sort the set of unions. (select orderno ) union (select orderno ) order by orderno. Not necessary now (no sense), to use order by in selects inside union. C.