select p.prod_name, oi.quant_sold from Products p left join ( -- 左连接一个子查询 select prod_id, sum(quantity) as quant_sold from OrderItems group by prod_id -- 先分组再使用聚合函数 ) oi on p.prod_id = oi.prod_id;