数据库查询语句。
- 查询出一班出生在1995年以后的所有学生。 select name from students where class = 1 and Year(birthday) > 1995;
- 查询张三在2016年的平均成绩。 select avg(b.score) from students a, scores b where a.num = b.num and a.name = "张三" and b.year = 2016;
- 查询各科成绩都高于80分的姓张的学生。 select distinct(name) from students where name not in (select name from students where score < 80) and name like "张%"; 或 select name from students group by name having min(score) > 80 and name like "张%";
- 查询班级科目a成绩高于本班科目a平均分的所有同学。 select name from students, (select class_id, avg(subA_score) as av_score from students group by class_id) av where students.class_id = av.class_id and students.subA_score > av.av_score;
- sql常见面试题 https://www.cnblogs.com/diffrent/p/8854995.html