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 |
|
markandan26
Starting Member
3 Posts |
Posted - 2012-07-23 : 01:06:47
|
| I'm having two column in a table. i want to update by comparing two columns. If the record will be same update as "duplicate" in third column This is the Query. It will work but it compare single column and update as duplicateexID Org Country Duplicate1 Harvard University United Status 2 Harvard University United Kingdom3 Harvard University United Status DuplicateMore than record in a table as same return duplicate.Please help me......Thank u......Markandan M |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-07-23 : 02:19:11
|
select ID, Org, Country, case when rnum > 1 then 'Duplicate' else '' end as Duplicatefrom(select row_number() over (partition by Org,Country order by ID) as rnum,* from YourTable)dt No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|