Re: simulate union in subselect

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Wei Weng <wweng(at)kencast(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: simulate union in subselect
Date: 2001-04-26 15:44:47
Message-ID: Pine.LNX.4.30.0104261743360.758-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Wei Weng writes:

> I know this is not do-able, but is there any way to simulate the
> following in Postgresql 7.1?
>
> select id from
> (select id, recv_date as date from table1
> union
> select id, send_date as date from table2) AS subtable
> order by date;

I haven't actually tried whether this does not work, but ISTM that you
could simply do

select id, recv_date as date from table1
union
select id, send_date as date from table2
order by 2;

and ignore the second column when processing the result.

--
Peter Eisentraut peter_e(at)gmx(dot)net http://funkturm.homeip.net/~peter

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Peter J. Schoenster 2001-04-26 15:58:59 Re: must I create the function check_primary_key ?
Previous Message Vivek Khera 2001-04-26 15:37:56 Re: MySql 'REPLACE'