ITPub博客

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

SQL解惑二:谜题43 毕业

原创 Oracle 作者:hu825065235 时间:2014-07-23 09:13:37 0 删除 编辑


解答:
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/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-02-26

  • 博文量
    34
  • 访问量
    83412