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 |
|
angel9
Starting Member
10 Posts |
Posted - 2009-04-08 : 09:52:03
|
| Please help on the following query: Exclude students who receive S loan and NO P loan and have 6 or more credit hours. (Select statement only)Your help is greatly appreciated again.Original table looks like this; ID CREDIT DETAIL_CODE CAT_CODE1 9 S FA1 4 P FA2 3 S FA2 4 P FA3 9 S FA4 3 S FAResults will look like this: ID CREDIT DETAIL_CODE CAT_CODE1 9 S FA1 4 P FA2 3 S FA2 4 P FA4 3 S FA |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-04-08 : 10:11:24
|
| select * from your_table as t1inner join (select id from your_tablegroup by idhaving sum(case when DETAIL_CODE ='S' and credit>6 then 1 else 2 end)>1) as t2on t1.id=t2.idMadhivananFailing to plan is Planning to fail |
 |
|
|
angel9
Starting Member
10 Posts |
Posted - 2009-04-08 : 13:33:07
|
It is great! thank you very much for your help!quote: Originally posted by madhivanan select * from your_table as t1inner join (select id from your_tablegroup by idhaving sum(case when DETAIL_CODE ='S' and credit>6 then 1 else 2 end)>1) as t2on t1.id=t2.idMadhivananFailing to plan is Planning to fail
|
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-04-09 : 02:16:36
|
quote: Originally posted by angel9 It is great! thank you very much for your help!quote: Originally posted by madhivanan select * from your_table as t1inner join (select id from your_tablegroup by idhaving sum(case when DETAIL_CODE ='S' and credit>6 then 1 else 2 end)>1) as t2on t1.id=t2.idMadhivananFailing to plan is Planning to fail
You are welcome MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|