题解 | #返回产品名称和每一项产品的总订单数#
返回产品名称和每一项产品的总订单数
http://www.nowcoder.com/practice/1c64fd9048364a58a8ffa541720359a4
select prod_name,if(orders is null,0,orders) orders
from Products p
left join (select prod_id,count(order_num) orders
from OrderItems oi
group by prod_id)newtable
on p.prod_id=newtable.prod_id
order by prod_name