首页 > 试题广场 >

MySQL中有两数据表,student表记录学生信息、sco

[问答题]

MySQL中有两数据表,student表记录学生信息、score记录某次考试成绩,如下所示。

请根据数据表给出SQL语句,统计每位女学生的平均成绩。



select AVG(成绩) as 平均成绩 from student,score where student.性别=‘女’ and student.学号=score.学号


发表于 2020-03-13 20:07:40 回复(1)
select 姓名 '姓名', stu.学号 '学号', avg(成绩) '成绩' from student stu left join score sc on stu.学号 = sc.学号 where 性别='女' group by stu.学号, 姓名;
发表于 2020-04-14 22:12:48 回复(1)
select st.姓名, avg(sc.成绩)
from student st left join score sc on st.学号=sc.学号
where st.性别='女'
group by st.姓名
发表于 2020-03-22 10:46:38 回复(0)
标准答案1:SELECT A.xuehao,AVG(B.cj)FROM  STUDENT A,SCORE B WHERE A.xuehao=B.xuehao  AND A.xb=‘女’ GROUP BY A.xuehao;   因为每个人的学号对应了多个学科,分组后就都在一起了,然后用AVG算平均数。
标准答案2内连接方式:select s.学号 ,s.姓名,s.性别, sc.科目,avg(sc.成绩) form student  s inner join score  sc where s.性别='女'
编辑于 2020-05-19 16:05:32 回复(0)

SELECT 学号,姓名,性别,avg(成绩)平均成绩

from(SELECT 学号,姓名,性别,科目,成绩

from student join score on student.学号=score.学号

)A

where 性别=女

group by 1,2;

发表于 2023-07-12 09:51:14 回复(0)
select AVG(成绩) as 平均成绩 from student, score where student.性别=‘女’ and student.学号=score.学号
发表于 2021-03-13 21:26:19 回复(0)
select sid,average(成绩) from score where sid in(select sid from student where gender is male);
发表于 2020-08-28 21:50:12 回复(0)
<p>select student,avg(成绩)from (select avg(成绩)from score group by 学号),student where student.学号=score.学号 and student.性别=‘女’</p>
发表于 2020-07-27 00:12:26 回复(0)
select average(select 成绩 from score where score.学号=student.学号  )from student  where 性别=女  group by 学号
发表于 2020-04-24 13:48:43 回复(0)
Select score.no AVG(score.grade)
from student,score
where student.sex='女' and score.no=student.no
group by student.no;
发表于 2020-04-16 02:02:29 回复(0)
select '姓名',avg(成绩) from student as stu left join score sco in stu.学号=sco.学号
where '性别'=‘女’
group by '学号'
发表于 2020-04-07 18:11:59 回复(0)

select student.姓名,student.学号,student.性别,average(score.成绩) from student,score where student.学号=score.学号 and student.性别=“女”;


发表于 2020-02-23 12:32:40 回复(0)