标签:结果 order 最好 iso pre 不同 .com logs each
select sc.cid,c.cname,count(distinct sid) as ‘stuCount‘ from sc sc,course c
where sc.cid=c.cid
group by sc.cid,c.cname;
select distinct sc1.sid,sc1.cid,sc1.score from sc sc1,sc sc2
where sc1.cid!=sc2.cid and sc1.score=sc2.score
order by sc1.score asc;
select sc.cid,c.cname,sc.sid,s.sname,sc.score from student s,sc sc,course c
where s.sid=sc.sid and sc.cid=c.cid and sc.score in
(
select sc2.score from sc sc2
where sc2.cid=sc.cid
order by sc2.score desc limit 2
)
order by sc.cid;
select sc.Cid,COUNT(distinct Sid) as ‘StuCount‘ from SC sc
group by sc.Cid
having COUNT(distinct Sid)>=10
order by StuCount desc,sc.Cid asc
select distinct sc.sid from sc sc
group by sc.sid
having count(sc.cid)>=2;
select sc.cid,c.cname from sc sc,course c
where sc.cid=c.cid
group by sc.cid,c.cname
having count(sc.sid)=(select count(distinct s.sid) from student s)
select s.sname from student s where s.sid not in
(
select sc.sid from sc sc,course c,teacher t
where sc.cid=c.cid and c.tid=t.tid and t.tname=‘叶平‘
)
select sc.sid,avg(ifnull(sc.score,0)) as ‘AvgScore‘ from sc sc
where sc.sid in
(select sc2.sid from sc sc2
where sc2.score<60
group by sc2.sid
having count(sc2.cid)>2
)
group by sc.sid;
select sc.Sid from SC sc
where sc.Cid=‘004‘ and sc.Score<60
order by sc.Score desc
文章转载自 https://www.cnblogs.com/edisonchou/p/3878135.html
欢迎加入数据分析交流群(加群备注博客园)
标签:结果 order 最好 iso pre 不同 .com logs each
原文地址:https://www.cnblogs.com/linxiaochi/p/9650361.html