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 |
|
ladiaocb
Yak Posting Veteran
57 Posts |
Posted - 2004-08-27 : 11:45:57
|
| I am trying to write a query that will give me the duplicates in a table. For example:ID FirstName Lastname Extension1 Bob David 43252 Steve Kerr 23453 Joe Plum 43254 Dan Man 8934I want to return ID 1 and 3 since they are dups. Please help! |
|
|
gpl
Posting Yak Master
195 Posts |
Posted - 2004-08-27 : 11:54:35
|
try thisSelect ID, YT.Extensionfrom {YourTableName} YTJoin( select Extension, count(*) from {YourTableName} group by Extension having Count(*) > 1) DTon YT.Extension = DT.ExtensionGraham |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-08-27 : 11:57:12
|
| select *from MyTable t1inner join (select Extension from MyTable group by Extension having Count(*)>1) t2 on t1.Extension = t2.ExtensionGo with the flow & have fun! Else fight the flow :) |
 |
|
|
ladiaocb
Yak Posting Veteran
57 Posts |
Posted - 2004-08-27 : 12:07:30
|
| Thanks! That worked!!! |
 |
|
|
|
|
|