SQL数据库命令,求救查询平均成绩!
select 学号, avg(分数) from grade group by 学号 having count(distinct 课程编号) > 1
select 学号 as u_编号, 姓名 as u_名称
from student_info where 姓名 like '张%'
union
select 课程编号 as u_编号, 课程名称 as u_名称
from curriculum
select 学号, avg(分数) from grade group by 学号 having count(distinct 课程编号) > 1;
我看这种不要用union了吧,不然数据排列不好看吧。。。。。
select grade.学号 as u_学号,curriculum.课程编号 as u_编号,curriculum.课程名称 as u_名称。
from curriculum,grade,student_info
where where student_info.姓名 like '张%' and student_info.学号=grade.学号
and grade.课程编号=grade.课程编号
1,select b.学号,b.姓名,avg(a.分数) as 平均分 from grade a inner join student_info b on a.学号=b.学号 group by b.学号,b.姓名 having count(*)>=2
2, create table newTable as
select 学号 as u_编号, 姓名 as u_名称
from student_info where 姓名 like '张%'
union all
select 课程编号 as u_编号, 课程名称 as u_名称
from curriculum
select 学号, avg(分数) from grade group by 学号 having count(distinct 课程编号) > 1
select 学号 as u_编号, 姓名 as u_名称
from student_info where 姓名 like '张%'
union
select 课程编号 as u_编号, 课程名称 as u_名称
from curriculum
老师给的ppt里面有方法,套进去就ok啦