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 |
|
davidmal
Starting Member
19 Posts |
Posted - 2007-02-08 : 22:28:31
|
| Yet another simple query that is eluding me. I need to find records in a table that have the same first name and last name. Because the table has a primaty key, these people were entered twice or they share the same first and last name.How could you query this: ID fname lname 10001 Bill Jones 10002 Joe Smith 10003 Sue Jenkins 10004 John Sanders 10005 Joe Smith 10006 Harrold Simpson 10007 Sue Jenkins 10008 Sam Worden and get a result set of this:ID fname lname 10002 Joe Smith 10005 Joe Smith 10003 Sue Jenkins 10007 Sue Jenkins |
|
|
intergalacticplanetary
Starting Member
12 Posts |
Posted - 2007-02-08 : 23:30:03
|
| SELECT ID, fname, lnameFROM tableORDER BY fname, lname; |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-02-08 : 23:32:17
|
[code]select t.*from table1 tinner join ( select fname, lname from table1 group by fname, lname having count(*) > 1) don t.fname = d.fnameand t.lname = d.lname[/code] KH |
 |
|
|
|
|
|