关于#sql#的问题,请各位专家解答!

img

向上图这样的情况 应该用哪种方法进行联表查询

第一个问题我写出来了,不知道对不对


select class 班级,countcase when sex='男' then 1 endas 男,
countcase when sex='女' then 1 endasfrom table1 group by class
1.
select `class`,count(id), sex from table1 group by class,sex

2.
select a.`class`, a.name, b.Yw,b.Sx from table1 a lfet join table2 b on a.id = b.id

3.
select `class`,count(*) from table1 a left join table2 b on a.id = b.id and b.Yw > 90 group by class

4.
update table2 set Yw = 95 where id = 'E9C74592A90C21D8E0533903190A764A'

1.实现查询每个班级每个人语文、数学分别多少分

SELECT a.`code`,a.class,a.`name`,a.sex,b.Yw,b.Sx FROM class a LEFT JOIN person b on a.id=b.id

2.查询每个年级语文90分以上有多少个人

SELECT
    a.class,COUNT(1) AS 'number'
FROM
    class a
LEFT JOIN person b ON a.id = b.id
WHERE
    b.Yw > 90 GROUP BY class

3.修改一年级张三语文 成绩修改成95分

UPDATE person SET Yw=95 WHERE id=(SELECT id FROM class WHERE name='张三' AND class='一年级')