今天的答案


select s1.sid from (
SELECT sid,score from sc where cid='001') s1
join (SELECT sid,score from sc where cid='002') s2
on s1.sid=s2.sid
where s1.score > s2.score
GROUP BY sid;

select sid,AVG(score) as av from sc
GROUP BY sid
HAVING (AVG(score) > 60);

select sc.sid,b.sname,COUNT(1),SUM(score) from sc
right join student b on sc.sid = b.sid
GROUP BY sc.sid;

select count(1) from teacher
where tName like '刘%';

select a.sid,sname from sc a
left join student b on a.sid =b.sid
where a.sid not in
(select sid from sc a
where a.cid in
(select cid from teacher a
left join course b on a.tid = b.tid
where tName like '李%')
GROUP BY sid)
GROUP BY a.sid;

select a.sid,b.sname from
(select sid from sc where cid = '001') a
left join student b on a.sid = b.sid
where a.sid in
(select sid from sc
where cid = '002');

select a.sid,sname from sc a
left join student b on a.sid = b.sid
where a.cid in
(select cid from teacher a
left join course b on a.tid = b.tid
where tName like '李%')
GROUP BY sid
HAVING count(1)=
(select count(1) from teacher a
left join course b on a.tid = b.tid
where tName like '李%');


select s1.sid,b.sname from (
SELECT sid,score from sc where cid='001') s1
join (SELECT sid,score from sc where cid='002') s2
on s1.sid=s2.sid
left join student b on s1.sid = b.sid
where s1.score > s2.score
GROUP BY s1.sid;

select a.sid,sname from
(select sid,count(1) s from (select sid from sc) a GROUP BY sid) a
left join
(select sid,count(1) s from (select sid from sc where score<60 ) a GROUP BY sid) b on a.sid = b.sid
left join student c on a.sid=c.sid
where a.sid=b.sid and a.s=b.s;

select a.sid,sname from
(select a.sid,count(1) s from sc a GROUP BY sid) a
left join student b on a.sid=b.sid
where a.s = (select count(1) from course);

 

posted @ 2020-10-21 20:48  亲爱的达瓦里氏  阅读(133)  评论(0)    收藏  举报