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 |
|
munkdogg
Yak Posting Veteran
53 Posts |
Posted - 2007-10-29 : 15:46:13
|
| Hello,I searched for all the posts which covered my question - but none were close enough to answer what i'm trying to do. Basically, the scenario is thus;Table1 contains values for UserID, Account code, and Date.My query (below) is trying to find all the accounts assigned to a particular user ID, but also those duplicate account codes which belong to a second user ID. The date column would be appended to the result set.The query I'm using is as follows;select acccountcode, userid, date from dbo.table1where exists (select accountcode from dbo.table1 where accountcode = table1.accountcodegroup by accountcodehaving count(*) > 1)and userid = 'x-x-x'order by accountcodeWhat I think this produces is a list of all files where a duplicate exists, but of course it leaves out the 2nd UserID...which is crucial.Hopefully this makes sense. Any insight my fellow DBA's can share would be greatly appreciated!Thanks,D. |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|