首页 > 数据库 > Oracle > SQL解惑二:谜题43 毕业

解答:
select N.student_name,
(case
when sum(n.sf) > 0 then
'N'
end) as 不予毕业,
(case
when sum(n.sf) = 0 then
'Y'
end) as 给予毕业
from (select a.student_name,
a.credit_cat,
a.fs,
rqd_credits,
(case
when a.fs - rqd_credits > 0 then
0
else
1
end) as sf
from (select distinct student_name,
credit_cat,
sum(credits) over(partition by student_name, credit_cat) as fs
from creditsearned
order by 1) a
join Categories c
on (a.credit_cat = c.credit_cat)) N
group by n.student_name
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29507357/viewspace-1225020/ ,如需转载,请注明出处,否则将追究法律责任。