From: | Bruno Wolff III <bruno(at)wolff(dot)to> |
---|---|
To: | WeiShang <thanks(at)verymuch(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: VIEW / ORDER BY + UNION |
Date: | 2005-02-23 17:19:57 |
Message-ID: | 20050223171957.GA15830@wolff.to |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Thu, Feb 17, 2005 at 23:46:59 +0800,
WeiShang <thanks(at)verymuch(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | KÖPFERL Robert | 2005-02-23 18:33:07 | Re: VIEW / ORDER BY + UNION |
Previous Message | Michael Fuhr | 2005-02-23 16:51:58 | Re: Row Count |