pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: WeiShang <thanks@verymuch.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: VIEW / ORDER BY + UNION
Date: Wed, 23 Feb 2005 11:19:57 -0600
Message-ID: <20050223171957.GA15830@wolff.to> (raw)
In-Reply-To: <cv2ea4$1cfv$2@news.hub.org>
References: <cv2ea4$1cfv$2@news.hub.org>

On Thu, Feb 17, 2005 at 23:46:59 +0800,
  WeiShang <thanks@verymuch.com> wrote:
> 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?

If this isn't a made up example, you don't want to do this. You
should use IN or OR to select records corresponding to the days
of interest and then use ORDER BY to select the ordering.



view thread (5+ messages)  latest in thread

Message-ID: <20050223171957.GA15830@wolff.to>
Permalink:  ../20050223171957.GA15830@wolff.to/
Also on:    postgresql.org/message-id/20050223171957.GA15830@wolff.to

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: bruno@wolff.to, thanks@verymuch.com
  Subject: Re: VIEW / ORDER BY + UNION
  In-Reply-To: <20050223171957.GA15830@wolff.to>

* 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