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 7255F8B9EA5 for ; Wed, 23 Feb 2005 18:33:16 +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 91701-09 for ; Wed, 23 Feb 2005 18:33:12 +0000 (GMT) Received: from mx-00.sil.at (mx-00.sil.at [62.116.68.196]) by svr1.postgresql.org (Postfix) with ESMTP id 6EE6A8B9E80 for ; Wed, 23 Feb 2005 18:33:10 +0000 (GMT) Received: (qmail-ldap/ctrl 15347 invoked from network); 23 Feb 2005 18:33:06 -0000 Received: from unknown (HELO jupiter.sonorys.at) ([213.235.243.42]) (envelope-sender ) by mx-00.sil.at (qmail-ldap-1.03) with SMTP for ; 23 Feb 2005 18:33:06 -0000 Received: from neptun.sonorys.at (neptun.sonorys.at [172.24.1.17]) by jupiter.sonorys.at (8.11.7+Sun/8.11.7) with ESMTP id j1NIXYs11383 for ; Wed, 23 Feb 2005 19:33:34 +0100 (MET) Received: by neptun.sonorys.at with Internet Mail Service (5.5.2653.19) id ; Wed, 23 Feb 2005 19:33:11 +0100 Message-ID: From: =?ISO-8859-1?Q?K=D6PFERL_Robert?= To: Cc: pgsql-sql@postgresql.org Subject: Re: VIEW / ORDER BY + UNION Date: Wed, 23 Feb 2005 19:33:07 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="ISO-8859-1" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.572 tagged_above=0 required=5 tests=AWL, SUBJ_ALL_CAPS, UPPERCASE_25_50, URIBL_SBL X-Spam-Level: X-Archive-Number: 200502/277 X-Sequence-Number: 20387 Otherwise you can treat this as a subselect and suround it with another select. Like select * from () order by orderno; C:\> -----Original Message----- C:\> From: Bruno Wolff III [mailto:bruno@wolff.to] C:\> Sent: Mittwoch, 23. Februar 2005 18:20 C:\> To: WeiShang C:\> Cc: pgsql-sql@postgresql.org C:\> Subject: Re: [SQL] VIEW / ORDER BY + UNION C:\> C:\> C:\> On Thu, Feb 17, 2005 at 23:46:59 +0800, C:\> WeiShang wrote: C:\> > Hi, I have created a view like this : C:\> > C:\> > CREATE VIEW v1 AS (SELECT orderno,weekday,time FROM t1,t2 where C:\> > t1.orderno=t2.orderno); C:\> > C:\> > if I create a SQL statment: C:\> > C:\> > (SELECT orderno FROM v1 WHERE weekday='MON' ORDER BY orderno) C:\> > UNION C:\> > (SELECT orderno FROM v1 WHERE weekday='WED' ORDER BY orderno) C:\> > UNION C:\> > (SELECT orderno FROM v1 WHERE weekday='FRI' ORDER BY orderno); C:\> > C:\> > Will the whole result will be sorted by the field orderno? C:\> C:\> If this isn't a made up example, you don't want to do this. You C:\> should use IN or OR to select records corresponding to the days C:\> of interest and then use ORDER BY to select the ordering. C:\> C:\> ---------------------------(end of C:\> broadcast)--------------------------- C:\> TIP 7: don't forget to increase your free space map settings C:\>