标签:avg 大于 student 个数 函数 总成绩 span gen core
所以大于六十分的
SELECT * from score where num > 60;
所有老师以及所教课程
select teacher.tname, course.cname from course
left join teacher on course.teacher_id = teacher.tid;
男生个数以及女生个数
select gender,count(gender) from student group by gender;
临时表-在内存中临时存在
select sid from (select * from score where num > 60)as B;
查询生物比物理课成绩高的所有学生学号
查询平均成绩大于60的同学的学号和平均成绩
select student_id,avg(num) from score group by student_id having avg(num) > 60;
查询平均成绩大于60的同学的学号和平均成绩和姓名
select student.sname,b.student_id,b.ccc from (select student_id,avg(num) as ccc from score group by student_id having avg(num) > 60) as b
left join student on student.sid = b.student_id; 注意聚合函数
查询所有同学的学号,姓名,选课数,总成绩;
select student_id,student.sname,count(course_id),sum(num) from score left join student on score.student_id = student.sid
group by student_id;
标签:avg 大于 student 个数 函数 总成绩 span gen core
原文地址:https://www.cnblogs.com/kateli/p/9208252.html