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 |
|
rusmo
Starting Member
2 Posts |
Posted - 2005-08-17 : 14:07:47
|
| I have a customer table with two VARCHAR columns:customerId (primary key)hardwareIdIt is possible for more than one customer to have the same hardwareId. I need to know how to query this table to return a list of customer records (rows) that have non-unique hardwareId's. To be clear, here is a sample table and the sample results I wish to get back from the query:SAMPLE TABLE (customerID, hardwareID):0, A1, B2, B3, C4, D5, DDESIRED RESULTS (customerID, hardwareID):1, B2, B4, D5, DThanks in advance for the help! |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2005-08-17 : 14:12:18
|
| Well what you say you want is not what your result is...so to get your result setSELECT * FROM myTable99 WHERE harwareID IN (SELECT HarwareID FROM myTable99 GROUP BY harwareID HAVING COUNT(*) > 1)Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx |
 |
|
|
rusmo
Starting Member
2 Posts |
Posted - 2005-08-17 : 15:13:33
|
| Thanks! The 'HAVING COUNT' part was where I was fuzzy. |
 |
|
|
|
|
|
|
|