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 |
|
actuary
Starting Member
23 Posts |
Posted - 2008-11-05 : 07:39:53
|
| Hi, I have a table with this kind of dataName Valaaa 1aaa 2bbb 3aaa 3aaa 4bbb 4I just need to get the records where its ((Val=1 or Val=2) AND (Val=3 or Val=4)), in the above case it would only be aaa.Need help! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-05 : 07:44:21
|
| [code]SELECT NameFROM Table GROUP BY NameHAVING SUM(CASE WHEN Val=1 OR Val=2 THEN 1 ELSE 0 END)>0AND SUM(CASE WHEN Val=3 OR Val=4 THEN 1 ELSE 0 END)>0[/code] |
 |
|
|
actuary
Starting Member
23 Posts |
Posted - 2008-11-05 : 08:01:45
|
| you simply ROCK sir! thankssss! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-05 : 08:03:05
|
Cheers |
 |
|
|
|
|
|