学习目标:
sql
学习内容:
接第五周内容,算了一下时间,发现从第一周开始,还有四周内容没补(过年没发),这周陆续补上
结果在写的过程中mysql被我搞崩了,心累
7.求每门课程的学生人数
分析:按课程分组,统计学生数,涉及两个表
select course.name,count(score.stunm) from score,course where score.counm=course.counm group by course.counm,course.name;
8.查询8周前过生日的学生
分析:week()
select name,birthday from students where week(birthday)=week(now())-8;
参考答案:
select *from students where WEEKOFYEAR(students.birthday)=WEEKOFYEAR(CURDATE())-8;
不知道为啥少了一行,知道的大佬评论跟我说下哈(* ̄︶ ̄)
9.查询下周过生日的学生
分析:week()
select name,birthday from students where week(birthday)=week(now())-1;
10.查询12月过生日的学生
分析:month()
select name,birthday from students where month(birthday) like ‘%12%’;
11.查询下月过生日的学生
分析:month()
select name,birthday from students where month(birthday) +1;
12.统计每门课程的学生选修人数(超过 5 人的课程才统计)
分析:根据课程分组,学生人数大于5
select counm,count(stunm) from score group by counm having count(stunm)>5;
学习时间:
1月-3月,每天一小时左右
学习产出:
一周一发