zoukankan      html  css  js  c++  java
  • python学习之老男孩python全栈第九期_数据库day004 -- 作业

    https://www.cnblogs.com/YD2018/p/9451809.html

    11. 查询学过“001”并且也学过编号“002”课程的同学的学号、姓名

    select student.sid,student.sname from score LEFT JOIN student on score.student_id=student.sid where (course_id=1 or course_id=2) GROUP BY score.student_id having count(course_id)>1


    12. 查询学过“李平”老师所教的所有课的同学的学号、姓名

    SELECT student.sid,student.sname from score LEFT JOIN student on score.student_id=student.sid where score.course_id in (SELECT course.cid from course where course.teacher_id=(select teacher.tid from teacher where teacher.tname='李平老师')) GROUP BY score.student_id having count(score.course_id) = (SELECT count(course.cid) from course where course.teacher_id=(select teacher.tid from teacher where teacher.tname='李平老师'));


    13. 查询有课程成绩小于60分的同学的学号、姓名

     一. group by 做:

    SELECT student.sid,student.sname from score LEFT JOIN student ON score.student_id=student.sid where score.num<60 group by score.student_id;

    二. distinct  做:

    去重:distinct -- 效率不高
    SELECT distinct student.sid,student.sname from score LEFT JOIN student ON score.student_id=student.sid where score.num<60;

    14. 查询没有学全所有课的同学的学号、姓名

    SELECT student.sid,student.sname from score LEFT JOIN student ON score.student_id=student.sid where score.course_id in (SELECT course.cid from course) GROUP BY score.student_id having count(score.course_id) !=(SELECT count(course.cid) from course);

  • 相关阅读:
    POJ-1004-Finanical Management
    POJ-1003-hangover
    第一次写博客,想了很久要给自己留一个什么样的开始
    从exchange2010上面删除特定主题或特定时间的邮件
    STM32 一个定时器产生4路 独立调频率,占中比可调,脉冲个数可以统计。
    光电耦合
    STM32 定时器级联
    Eclipse 创建新的workspace
    一次提交,多文件上传
    Grid标签计算结果集中的合计行
  • 原文地址:https://www.cnblogs.com/lpgit/p/9456952.html
Copyright © 2011-2022 走看看