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 |
|
eurob
Posting Yak Master
100 Posts |
Posted - 2006-01-26 : 11:14:12
|
if I do this query it shows me the records with duplicate names:select firstname,lastname,statusid from employees group by firstname,lastname,statusidhaving count(*) > 1 I would like to see all the ones that are duplicate with their record id, example:recid....firstname....statusid ------------------------------1..........Joe..........TERM45........Joe..........EMPLOYEEIs there a way to do this ?robert |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-01-26 : 11:43:53
|
| TrySelect e.* from employees eInner Join(Select firstname, statusid from employees group by firstname, statusid having count(*) > 1) Qry1on e.firstname = Qry1.firstname and e.statusid = Qry1.statusid |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-01-26 : 20:07:41
|
| [code]select e.recid, e.firstname, e.statusidfrom employees einner join ( -- this is your duplicate names query select firstname, lastname, statusid from employees group by firstname, lastname, statusid having count(*) > 1) as don e.firstname = d.firstnameand e.lastname = d.lastnameand e.statusid = d.statusid[/code]----------------------------------'KH' |
 |
|
|
|
|
|
|
|