笔试题目题目如下:

1、 查出每门课都大于80分的学生的姓名
方法1
select name from scores group by name having min(fenshu)>80;
方法2
select distinct name from scores where name not in (select distinct name from scores where fenshu<=80)
2、查询平均分大于80的学生姓名
方法1
select name, avg(fenshu) as sc from scores group by name having avg(fenshu)>80;
方法2
select name from (
select count(*) t, sum(fenshu) num, name from scores group by name
) as a where a.num>80*t;
本文解析了两道SQL笔试题目,包括如何查询每门课成绩都大于80分的学生姓名及查询平均分大于80分的学生姓名的方法。提供了两种不同的查询方式,深入探讨了SQL聚合函数和子查询的应用。
227

被折叠的 条评论
为什么被折叠?



