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 |
|
SQL_Rookie
Starting Member
32 Posts |
Posted - 2009-09-23 : 16:29:56
|
| I got a simple query that I can not figure out right now...table looks like thiscolumn text column numberABC 123ABC 123ABC 123DEF 145DEF 148DEF 123XYZ 345I want the query to return rows that have the same column number for every row that has the same column text...in the above example I only would want to return ABC and the XYZ rows....the DEF have different column numbers. |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-09-23 : 16:36:38
|
maybe this:select [column text] ,min([column number]) as [column number]from [table]group by [column text]having count(distinct [column number]) = 1EDIT:--this would work too:having min([column number]) = max([column number]) Be One with the OptimizerTG |
 |
|
|
SQL_Rookie
Starting Member
32 Posts |
Posted - 2009-09-23 : 16:47:32
|
| thanks....I could not think how I could do the group by but only return the ones that had the same column number....that min or the min = max does it.. |
 |
|
|
|
|
|