zoukankan      html  css  js  c++  java
  • 根据条件合并结果集

    原文 根据条件合并结果集

    第一个查询是将三个表中的列通过键连接起来,并将查询结果重命名为别名aaa;

    最后将两个查询的结果集aaa,bbb,通过 aaa.student_id = bbb.studentid连接起来。

     

    select aaa.*,bbb.required,bbb.elective from
    (select c.student_id,c.chinese_name,c.user_class, sum(decode(b.coursetype,1,a.credit,0)) get_required_total,sum(decode(b.coursetype,0,a.credit,0)) get_elective_total, sum(decode(b.coursetype,1,a.coursecredit,0)) reg_required_total,sum(decode(b.coursetype,0,a.coursecredit,0)) reg_elective_total
    from sm_course_student a,sm_courses b,sm_students c
    where a.course_id=b.courseid and a.student_id=c.student_id  and c.user_class like '10SH%' group by c.student_id,c.chinese_name,c.user_class
    
    )aaa,
    (select  studentid,required,elective from sm_school_roll where classname like '10SH%'
    
    )bbb
    where aaa.student_id = bbb.studentid
  • 相关阅读:
    最小生成树计数
    Tree
    NOJ 成绩排名
    NOJ 成绩排名
    NOJ 成绩排名
    NOJ 成绩排名
    NOJ Physics
    NOJ Physics
    NOJ Physics
    NOJ Physics
  • 原文地址:https://www.cnblogs.com/arxive/p/5959075.html
Copyright © 2011-2022 走看看