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 |
|
utleya
Starting Member
3 Posts |
Posted - 2002-08-28 : 14:26:55
|
| Hi all, I have a table that I need to queryto show only duplicate DocNums and an associated fieldcalled DocType.Example of desired output:DocNum DocType-------- ----------92-155 TOP92-155 ROP92-155 HOR02-999 TOP02-999 ROPThe following was suggested on another site, but will notwork with SQL Server:SELECT DocNum, DocTypeFROM leDocsWHERE (docnum, doctype) IN (SELECT docnum, doctype FROM ledocs GROUP BY docnum, doctype HAVING COUNT(*) > 1)ORDER BY docnum, doctypeAny help will be appreciated, thanks, Andy |
|
|
Onamuji
Aged Yak Warrior
504 Posts |
Posted - 2002-08-28 : 14:31:00
|
| the in is invalid in sql server i think ... try this insteadSELECT DocNum, DocType FROM leDocs WHERE (docnum) IN (SELECT docnum FROM ledocs GROUP BY docnum HAVING COUNT(doctype) > 1) ORDER BY docnum, doctype |
 |
|
|
|
|
|