Combining data from Temp Tables

From: Jeff Herman <hermanj(at)hvpa(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Combining data from Temp Tables
Date: 2012-02-21 17:04:22
Message-ID: DCD5B559B90AFB46B549AFD282BBE42692E3C3@BY2PRD0410MB388.namprd04.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all,

I have created two temp tables that I would like to combine to make a third temp table and am stuck on how to combine them to get the results I want. Any guidance you could give would be appreciated.

Temp Table 1 Temp Table 2
DATE LN MBRID DS DATE LN MBRID DS
1/1 A 1 30 1/1* A 1 -30
1/1 A 1 30
1/1 B 1 30

1/1 A 2 30 1/1* A 2 -30
1/1 A 2 30 1/1* A 2 -30

1/1 C 3 45

1/1 D 4 45 1/6* D 4 -45
1/1 D 4 45

*including and up to five days after Temp Table 1 DATE

I would like the Temp Table 3 to hold only the BOLD records above. In essence, it would compare and erase a record at a one to one ratio based on some fields being identical and the date range being on or within the next five days of Temp Table 1 date.

Thanks!

Jeff Herman
HVPA, Database Programmer
Phone: 734.973.0137 ext 441
Fax: 734.975.1248
hermanj(at)hvpa(dot)com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Herman 2012-02-21 17:31:46 Re: Combining data from Temp Tables
Previous Message Thomas Kellerer 2012-02-21 15:48:31 Re: How to store variable data in a field?