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 |
jribeiro
Starting Member
2 Posts |
Posted - 2010-11-22 : 11:29:55
|
Hi there I have a table like:A | B | C1 | Chair | Red2 | Table | Blue3 | Bed | Red4 | Table | Red5 | Chair | Green6 | Chair | BlueC is an enum type with the following possible values: "Red", "Blue" and "Green".I want to test if there is any value B that is used for all the colors C.In this case, Chair is used with all the colors so the result should be positive.I have some experience in SQL but I'm a bit clueless here.Can anyone help?Thanks |
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2010-11-22 : 11:35:10
|
SELECT B,count (distinct C)FROM yourTableGROUP BY BHAVING count(distinct C) = 3JimEveryday I learn something that somebody else already knew |
 |
|
jribeiro
Starting Member
2 Posts |
Posted - 2010-11-22 : 11:46:33
|
Thanks!!!!!! Worked great.I feel kind of ashamed :) ehheheh sometimes we get locked.Thanks once again |
 |
|
|
|
|