sql分组和聚集

 

select st.name na,co.NAME name,sc.score from scores sc
left join students st on sc.sid = st.id
left join courses co on co.id=sc.cid

共9门课程,获取成绩未填满的学生:

select t.na,count(*) from

(select st.name na,co.NAME name,sc.score from scores sc
left join students st on sc.sid = st.id
left join courses co on co.id=sc.cid) t

group by t.na having count(*)<9;

 

posted @ 2019-05-22 12:38  笔记Next  阅读(180)  评论(0编辑  收藏  举报