Re: UNION but with excused columns

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: Mike Rowan <michael(dot)rowan3(at)gmail(dot)com>
Cc: pgsql-novice novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: UNION but with excused columns
Date: 2018-05-28 01:42:06
Message-ID: CAKJS1f-rQVrJ6V4hBsed6ZeHBEFwi_R6shz8fvU51pGEM9GwDA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 28 May 2018 at 13:36, Mike Rowan <michael(dot)rowan3(at)gmail(dot)com> wrote:
> I would like to use UNION to amalgamate two result sets, but I need to
> excuse some columns (the same columns in each set) from the matching
> requirement. The unmatched columns are the same data type, but not the same
> data.
>
> Is this possible, and if so, any clues?

Yes, just use a sub-query: e.g: SELECT a,b,c FROM (SELECT a,b,c,d FROM
t1 UNION SELECT a,b,c,d FROM t2) t;

--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message john snow 2018-05-31 09:15:29 does postgresql 10 have something similar to sql server's set identity_insert
Previous Message Mike Rowan 2018-05-28 01:36:47 UNION but with excused columns