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 |
|
boehnc
Starting Member
15 Posts |
Posted - 2011-07-22 : 12:55:51
|
| Newbie obviously. Here's a simple dataset in my table:Student Date Grade 1 04/11 A 1 03/11 B2 04/11 A2 05/11 B2 06 11 B3 03/11 C3 04/11 AI want to filter on all those students who got "B's"...but I want to bring back all tests for those students. So when I filter for B, I want it to bring back all of Student 1 and 2's test grades, includeing the A's...best option? Any help is appreciated. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-07-22 : 13:01:36
|
| [code]SELECT t.*FROM Table tINNER JOIN (SELECT Student FROM Table GROUP BY Student HAVING SUM(CASE WHEN Grade='B' THEN 1 ELSE 0 END) > 0 ) t1ON t1.Student = t.Student[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|