select
o.no,s_order.no,sum(s_item.count),sum(after_sale_item.count)
from
buyer_order o
left join seller_order s_order on o.id = s_order.buyer_order_id
left join seller_order_item s_item on s_order.id = s_item.seller_order_id
left join seller_order_after_sale after_sale on s_order.id = after_sale.seller_order_id
left join seller_order_after_sale_item after_sale_item on after_sale.id = after_sale_item.after_sale_id
where o.add_time >='2019-05-01'
group by
o.id,s_order.id
order by
o.id
limit 0,10
select
o.id,o.no,s_order.no,
(select sum(sot.count) from seller_order so
left join seller_order_item sot on so.id = sot.seller_order_id
where so.id =s_order.id ),
(select sum(osat.count) from seller_order_after_sale osa
left join seller_order_after_sale_item osat on osa.id = osat.after_sale_id
where osa.seller_order_id = s_order.id )
from
buyer_order o
left join seller_order s_order on o.id = s_order.buyer_order_id
where o.addTime >='2019-05-01'
order by
o.id
limit 0,10