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 |
|
10Dawg
Starting Member
46 Posts |
Posted - 2011-01-31 : 16:36:55
|
| SELECT Ori_File_NameFROM Review_DocGROUP BY Ori_File_NameHAVING Count(Ori_File_Name) > 1andSELECT Ori_File_Name, Doc_IDFROM Review_Docboth work but.....SELECT Ori_File_Name, Doc_IDFROM Review_DocGROUP BY Ori_File_NameHAVING Count(Ori_File_Name) > 1does not work and gives an error message:Msg 8120, Level 16, State 1, Line 1Column 'Review_Doc.Doc_ID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.I need a list of Duplicate Ori_File_Name and their associated Doc_IDs. What am I doing wrong?10Dawg |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-01-31 : 16:51:12
|
SELECT Ori_File_Name, Doc_IDFROM Review_Docwhere Ori_File_Name in(SELECT Ori_File_NameFROM Review_DocGROUP BY Ori_File_NameHAVING Count(Ori_File_Name) > 1) No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|