select *,sum(product_retail) revenue,sum(product_cost) gross_profit,
round((sum(`product_retail`)-sum(`product_cost`))/sum(`product_retail`) * 100, 2) gross_profit_percent
from `combine_product` cp
left join `order_product` op on cp.product_id = op.product_id
where cp.is_parent = 1 group by op.product_id
1
liprais 2017-09-20 18:45:59 +08:00
select
your-select-list from ( select sum(product_retail) revenue,sum(product_cost) gross_profit from `combine_product` cp left join `order_product` op on cp.product_id = op.product_id where cp.is_parent = 1 group by op.product_id ) dt |
2
SummerWQM OP 明白 思路 嵌套一个
|