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 |
|
DSullSQL
Starting Member
3 Posts |
Posted - 2012-04-09 : 13:11:06
|
| I'm wondering if I can write a query to do the following.A sample set would be like thisPK Account # City1 1234 NY2 1234 NY3 1234 NY4 1234 NY5 5678 BOS6 5678 MINN7 5678 BOS8 5678 BOS9 9012 LA10 9012 LAThe city should be consistent for entries under a single account number. What I want to do is write a query that will return all the accounts that have inconsistencies in the City column.Thanks very much,D |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2012-04-09 : 13:31:57
|
| SELECT AccountFROM yourTableGROUP BY AccountHAVING COUNT(Distinct City) > 1JimEveryday I learn something that somebody else already knew |
 |
|
|
DSullSQL
Starting Member
3 Posts |
Posted - 2012-04-09 : 13:42:18
|
| Thanks Jim. |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2012-04-09 : 14:34:10
|
| You're welcome.Everyday I learn something that somebody else already knew |
 |
|
|
|
|
|