delimiter $
create procedure type(
in shuruxuehao VARCHAR(20),
out shuchuxuefen int(11)
)
BEGIN
set shuchuxuefen = 0;
set @num = 0;
set @xuefen = 0;
select sum(chengji1 +chengji2 + + chengjiN )/ n as num,xuefen into
@num, @xuefen from table where xuehao = shuruxuehao;/chengji 是各科成绩的字段/
if num >=60 then
set shuchuxuefen = @xuefen;
else
set shuchuxuefen = 0;
end if ;
END
$
delimiter ;这题目考的是关联查询、分组、排序等基础知识
1每科的平均成绩:
select avg(grade) from stu_grade group by course;
2每科的最高成绩及对应的学生信息:
select
Bgrade,
A
from stu_grade as B
left join stu_info as A on Bstu_No = Astu_No
group by Bcourse
order by Bgrade desc limit 1;
3每科的最低成绩及对应的学生信息:
select
Bgrade,
A
from stu_grade as B
left join stu_info as A on Bstu_No = Astu_No
group by Bcourse
order by Bgrade asc limit 1;
select start, end, avg(value) from (
select t2start, t2end, t1value from t1 left join t2 on t1key between t2start and t2end
) as x group by start,end;
效果见下图:
你好,很高兴回答你的问题。解决这个问题的大致sql是:
select 性别,avg(成绩) from 表 group by 性别;
如果有帮助到你,请点击采纳。
我解答的大部分是软件开发新人遇到的问题,如果有兴趣可以关注我。max(),avg(),sum(),case when 分数> then hege when 分数< then bu hege end as jibie from group by
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)