Home » SQL & PL/SQL » SQL & PL/SQL » Merging Records-Date selection
Merging Records-Date selection [message #7965] Fri, 18 July 2003 15:25 Go to next message
denise
Messages: 64
Registered: November 2000
Member
Hi

I have 2 records I am merging together but want to select the latest giftdate from either record, and
use that date as the merged date.

Example:
we are merging to the lowest IDNumber.

Idnumber 1001 giftdate 12/20/2002
Idnumber 2003 giftdate 7/20/2002

when we merge 2003 into 1001 we want 1001 to retain
it's own giftdate of 12/20/2002(latest giftdate).

however if:

Idnumber 1001 giftdate 6/30/2002
Idnumber 2003 giftdate 10/30/2002

we then want IDnumber 1001 to be updated with giftdate
10/30/2002.

would appreciated any help how to code this.

thanks
Re: Merging Records-Date selection [message #7967 is a reply to message #7965] Fri, 18 July 2003 15:47 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
update t
   set giftdate = (select giftdate
                     from t
                    where id = :id_to_lose)
 where id = :id_to_retain
   and giftdate < (select giftdate
                     from t
                    where id = :id_to_lose);
Thanks Todd-Re: Merging Records-Date selection [message #7976 is a reply to message #7967] Sat, 19 July 2003 07:18 Go to previous message
dadba
Messages: 34
Registered: February 2003
Member
your code definitely looks like it will solve what
I need.

thanks....
Previous Topic: Query help
Next Topic: query to retreive top 20 rows without using rowid
Goto Forum:
  


Current Time: Fri Apr 26 14:34:53 CDT 2024