Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Need help to solve update querry for multiple records.

$
0
0

Could any of you please provide update querry for the following scenario.

Requiremnt:

1. Update the UNIQUE_ID of record ( same Identifier and Identifier_code where END_Date is not null) with the UNIQUE_ID of the record (( same  Identifier and Identifier_codewhere END_Date  is null).

2. If More than one NULL in END_date then update UNIQUE_ID with max(EFFective_Date) of UNIQUE_ID

Source  data

---------------

UNIQUE_IDIdentifierIdentifier_codeEFFective_DateEND_Date
1777abc2/14/2014 11:152/28/2014 9:00
1777abc2/21/2014 9:003/7/2014 9:02
2777abc2/28/2014 9:003/14/2014 9:02
2777abc3/7/2014 9:023/14/2014 9:02
2777abc3/14/2014 9:02NULL
5888xyz2/14/2014 11:152/28/2014 9:00
5888xyz2/21/2014 9:003/7/2014 9:02
5888xyz2/28/2014 9:003/14/2014 9:02
6888xyz3/7/2014 9:02NULL
7888xyz3/14/2014 9:02NULL

OutPUT .

---------

UNIQUE_IDIdentifierIdentifier_codeEFFective_DateEND_Date
2777abc2/14/2014 11:152/28/2014 9:00
2777abc2/21/2014 9:003/7/2014 9:02
2777abc2/28/2014 9:003/14/2014 9:02
2777abc3/7/2014 9:023/14/2014 9:02
2777abc3/14/2014 9:02NULL
7888xyz2/14/2014 11:152/28/2014 9:00
7888xyz2/21/2014 9:003/7/2014 9:02
7888xyz2/28/2014 9:003/14/2014 9:02
7888xyz3/7/2014 9:02NULL
7888xyz3/14/2014 9:02NULL

Thanks in advance.

.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>