練習3--查詢全部同窗的學生編號、學生姓名、選課總數、全部課程的總成績

查詢全部同窗的學生編號、學生姓名、選課總數、全部課程的總成績spa

--解法一:code

select t2.s_id, t2.s_name, count(t1.c_id) as sun_course, sum(t1.s_score) as sum_score from student t2 left join score t1 on t1.s_id = t2.s_id group by t1.s_id

 

--參考解法:blog

select a.s_id, a.s_name, count(b.c_id) as sum_course, sum(b.s_score) as sum_score from student a left join score b on a.s_id = b.s_id group by a.s_id, a.s_name;

 

--2019/04/17class

相關文章
相關標籤/搜索