question

torpe avatar image
torpe asked

Selecting table with Duplicate records

I have a Table called Table1 and has a 'Name' column with 6 records as below:-

Jack,

John,

Jack,

Ram,

Hari and

Ram

Now I want the script that can give me like below:-

Name IsDuplicate

Jack No

John No

Jack Yes

Ram No

Hari No

Ram Yes


Please help.

Thanks

sql2012
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
anthony.green avatar image
anthony.green answered

Use something like row_number with a case which is partitioned on the name, and when the row_number is 1 the "NO", when > 1 then "YES"

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.