1. 程式人生 > >MySql 連結查詢時加入count,avg等操作時的方法

MySql 連結查詢時加入count,avg等操作時的方法

當sql語句要查詢總數又同時要查詢其他資料時,加上ROUND()

select a.*,ROUND(AVG(b.s_score),2),ROUND(count(b.s_score)) from

student a 
left join score b on b.s_id=a.s_id GROUP BY b.s_id HAVING ROUND(AVG(b.s_score),2)>60