本题目要求编写SQL语句,
在sc表
中查询平均成绩高于75分的学生。
表结构:
请在这里写定义表结构的SQL语句。例如:
CREATE TABLE `sc` (
`sno` char(4) NOT NULL,
`cno` char(4) NOT NULL,
`grade` decimal(6,1) DEFAULT NULL,
PRIMARY KEY (`sno`,`cno`),
);
表样例
请在这里给出上述表结构对应的表样例。例如
sc
表:
输出样例:
请在这里给出输出样例。例如:
--方法一
select sno as 学号,avg(grade) as 平均成绩
from sc where grade is not null
group by 学号 having avg(grade)>75
--方法二
select a.sno 学号,a.avg 平均成绩 from
(select sno ,avg(ifnull(grade,0)) avg from sc
group by sc.sno)a
where a.avg>75