suppose i have table student contain only single column ID
And it value for ID is
ID
1
1
2
3
2
4
4
So now i want to delete duplicate row and display out put is
ID
1
2
3
4
So how i write query. Please help me
Thanks in advance
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Vipan SharmaRank #1,589 · 999 reputationPosted Mar 19, 2016, 12:09 AM EDT
AS
(
SELECT Id,ROW_NUMBER() OVER(PARTITION by Id ORDER BY Id)
AS duplicateRecCount
FROM dbo.student
)
--Now Delete Duplicate Records
DELETE FROM TempStudent
WHERE duplicateRecCount > 1
select * from student
Rajeev PunhaniRank #551 · 4.4K reputationPosted Mar 19, 2016, 12:05 AM EDT
If the above solution is helpful then,accept the answer.
RAHUL PATIL128 reputationPosted Mar 19, 2016, 12:32 AM EDT
Vipan SharmaRank #1,589 · 999 reputationPosted Mar 19, 2016, 1:34 AM EDT