From: | "Wright, George" <George(dot)Wright(at)infimatic(dot)com> |
---|---|
To: | "Sean Davis" <sdavis2(at)mail(dot)nih(dot)gov> |
Cc: | "pgsql" <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: table unions |
Date: | 2008-08-08 15:59:40 |
Message-ID: | 51548D6D5BEB57468163194A8C1A0E980161A35E@MAGPTCPEXC02.na.mag-ias.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Sean,
TableA is non-overlapping contiguous durations of the lowest precedence.
TableB is a list of higher precedence durations that need to overlay the
records in TableA with any overlap trimmed away from the records in
TableA
The result is a contiguous non-overlapping combination of the two
tables.
I would imagine a nested case structure to do the trimming in the select
portion, but a join of the two tables would seem to be extremely large
and real performance problem. There are thousands of records in the two
tables.
Thanks.
-----Original Message-----
From: seandavi(at)gmail(dot)com [mailto:seandavi(at)gmail(dot)com] On Behalf Of Sean
Davis
Sent: Friday, August 08, 2008 11:50 AM
To: Wright, George
Cc: pgsql
Subject: Re: [NOVICE] table unions
On Fri, Aug 8, 2008 at 11:13 AM, Wright, George
<George(dot)Wright(at)infimatic(dot)com> wrote:
> Novice question:
>
> How can I apply conditional logic when doing a union of two tables?
>
> TableA TableB
> ------ ------
> value1 value2 value1 value2
> 1 10 5 15
> 11 20
>
> SELECT * FROM TableA UNION SELECT * FROM TableB;
> returns:
>
> value1 value2
> 1 10
> 5 15
> 11 20
>
>
> what I want is
>
> value1 value2
> 1 5
> 5 15
> 15 20
>
> The tables are huge and already in ascending order.
Hi, George.
What conditional logic are you trying to apply? Union will simply
take the rows from the two tables and combine them.
Sean
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Jackson | 2008-08-09 06:41:47 | Re: join group by etc |
Previous Message | Sean Davis | 2008-08-08 15:49:58 | Re: table unions |