Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Okay I'm back again with a different problem and table(s) How do I list the duplicates on the screen Tried this but it's giving me the NumOccurrences as 2 I want to see them as well.SELECT ProjNum,Rec1,Rec2, COUNT(ProjNum) AS NumOccurrencesFROM ProjectTableGROUP BY ProjNum, Rec1, Rec2HAVING ( COUNT(ProjNum) > 1 )My results:
SELECT *FROM ProjectTable P JOIN ( SELECT ProjNum,Rec1,Rec2, COUNT(ProjNum) AS NumOccurrences FROM ProjectTable GROUP BY ProjNum, Rec1, Rec2 HAVING COUNT(ProjNum) > 1 ) D ON P.ProjNum = D.ProjNum AND P.Rec1 = D.Rec1 AND P.Rec2 = D.Rec2
JJ297
Aged Yak Warrior
940 Posts
Posted - 2010-06-30 : 13:16:09
Yes I wanted to see the duplicate recoreds. Thanks Ifo your query did it.