Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
scelamko
Constraint Violating Yak Guru
309 Posts |
Posted - 2008-02-01 : 16:09:44
|
Guys,I have scenario where I have to update flag field based on the following data combination.Party_id count seq flag (TO BE POPULATED)____________________________________213777 1 1 Y213777 2 1 N213777 2 2 Y213778 1 1 N213778 1 2 N213778 1 3 Y213778 2 1 NThe logic to populate flag = 'Y' is to pick up the max seq field for the same combination of PARTY_ID and COUNT.Any suggestions and inputs would helpThanks |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2008-02-01 : 16:32:48
|
[code]update t set t.Flag = 'Y'from ( select Party_id ,[count] ,max(seq) seq from T group by Party_id ,[count] ) djoin T t on t.party_id = d.party_id and t.[count] = d.[count] and t.[seq] = d.[seq] [/code]Be One with the OptimizerTG |
|
|
|
|
|