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 |
|
sambrown18
Starting Member
14 Posts |
Posted - 2008-04-22 : 06:13:38
|
| I wont to search my table for repeated fields i wont to know what surnames are repeated.I think i need to use the count comand but not sure how i should integrate it |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-22 : 06:14:47
|
| SELECT surname from YourTable GROUP BY surname HAVING COUNT(*) > 1 |
 |
|
|
sambrown18
Starting Member
14 Posts |
Posted - 2008-04-22 : 06:22:12
|
| thanks that does work how do i put the second column in as well i need to see what surnames have what sessions |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-22 : 06:44:33
|
| SELECT surname,session,other fields... FROM YourTable WHERE surname in (SELECT surname from YourTable GROUP BY surname HAVING COUNT(*) > 1) |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-04-22 : 09:11:52
|
| orSELECT t1.* FROM YourTable t1 inner join (SELECT keycol,surname from YourTable GROUP BY surname HAVING COUNT(*) > 1) as t2on t1.keycol=t2.keycolMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|