Re: table unions
От | Wright, George |
---|---|
Тема | Re: table unions |
Дата | |
Msg-id | 51548D6D5BEB57468163194A8C1A0E980161A35E@MAGPTCPEXC02.na.mag-ias.net обсуждение исходный текст |
Ответ на | Re: table unions ("Sean Davis" <sdavis2@mail.nih.gov>) |
Список | 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@gmail.com [mailto:seandavi@gmail.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.Wright@infimatic.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
В списке pgsql-novice по дате отправления: