pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: KÖPFERL Robert <robert.koepferl@sonorys.at>
Cc: pgsql-sql@postgresql.org
Subject: Re: VIEW / ORDER BY + UNION
Date: Wed, 23 Feb 2005 19:33:07 +0100
Message-ID: <ED4E30DD9C43D5118DFB00508BBBA76EB165DC@neptun.sonorys.at> (raw)


Otherwise you can treat this as a subselect and suround it with another
select.

Like
select * from (<here goes your ex.>) 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 <thanks@verymuch.com> 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:\> 



view thread (5+ messages)  latest in thread

Message-ID: <ED4E30DD9C43D5118DFB00508BBBA76EB165DC@neptun.sonorys.at>
Permalink:  ../ED4E30DD9C43D5118DFB00508BBBA76EB165DC@neptun.sonorys.at/
Also on:    postgresql.org/message-id/ED4E30DD9C43D5118DFB00508BBBA76EB165DC@neptun.sonorys.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: robert.koepferl@sonorys.at
  Subject: Re: VIEW / ORDER BY + UNION
  In-Reply-To: <ED4E30DD9C43D5118DFB00508BBBA76EB165DC@neptun.sonorys.at>
  References: <ED4E30DD9C43D5118DFB00508BBBA76EB165DC@neptun.sonorys.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox