GROUP BYしたデータと別のテーブルの結合
グループ化した合計を出し、別のテーブルと結合し一覧を表示するときに使用
SELECT カラム,, FROM table1 LEFT JOIN table2 ON ?=? WHERE ? GROUP BY ?
(ORDER BY ?) ←省略可
例
SELECT a.id, a.group, a.delivery_date, a.nyukin, a.zaiko, SUM(b.price*b.kazu) as total_uriage, SUM(b.shiire*b.kazu) as total_shiire
FROM model as a LEFT JOIN goods_model as b ON a.id = b.cs_id
GROUP BY b.cs_id ORDER BY id, delivery_date DESC LIMIT 0 , 30