
1.select stu.*,t1.score 01分数,t2.score 02分数
from stu
left join (select * from sc where c_id='01') t1 on stu.s_id=t1.s_id
left join (select * from sc where c_id='02') t2 on stu.s_id=t2.s_id
where t1.score>t2.score;
2.select stu.s_id,avg(score)
from stu left join sc on stu.s_id=sc.s_id
group by stu.s_id
having avg(score)>60;
3.select stu.s_id,s_name,count(c_id) 选课门数,ifnull(sum(score),0) 总成绩
from stu left join sc on stu.s_id=sc.s_id
group by stu.s_id;
4.select count(t_id) from te where t_name like '李%';
5.select *
from stu
where s_id not in (select s_id
from sc
where c_id=(select c_id from te left join co on te.t_id=co.t_id where t_name='叶平'));
6.select stu.*
from stu left join sc on stu.s_id=sc.s_id
where c_id in (select c_id from co left join te on co.t_id=te.t_id where t_name='叶平');








暂无数据