• 博客园logo
  • 会员
  • 周边
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
gooliugle
博客园    首页    新随笔    联系   管理    订阅  订阅
根据条件合并结果集
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
posted on 2011-10-25 14:16  gooliugle  阅读(220)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3