zoukankan      html  css  js  c++  java
  • 查询选修了全部课程的学生名

    三张表:学生表student (Sno,Sname),  课程表course (Cno,Cname), 选课表SC(Sno,Cno)

    --选修了全部课程的学生名

    select  Sname from student where Sno in 
    (select Sno from SC group by Sno having count(*) =(select count(*) from course))

    --选修了部分课程的学生名

    select  Sname from student where Sno in 
    (select Sno from SC group by Sno having count(*) <(select count(*) from course))

    --没有选修课程的学生名

    select  Sname from student where Sno not in
    (select Sno from SC inner join course on SC.Cno = course.Cno group by Sno
    )
  • 相关阅读:
    hero
    今年暑假不AC
    Who's in the Middle
    A Simple Problem with Integers
    I hate it
    敌兵布阵
    Ordering Tasks
    Points on Cycle
    食物链
    c++ 14.0下载地址
  • 原文地址:https://www.cnblogs.com/shaosks/p/5239306.html
Copyright © 2011-2022 走看看