题解 | #某店铺的各商品毛利率及店铺整体毛利率#

某店铺的各商品毛利率及店铺整体毛利率

http://www.nowcoder.com/practice/65de67f666414c0e8f9a34c08d4a8ba6

select '店铺汇总' as pproduct_id,concat(round((1-sum(in_price*cnt)/sum(price*cnt))*100,1),'%') as profit_rate
from tb_product_info t join tb_order_overall t1 join tb_order_detail t2 on t.product_id = t2.product_id and t1.order_id = t2.order_id
where shop_id=901  and date(event_time)>='20211001'
union 
select *
from
(select t.product_id as pproduct_id,concat(round((1-sum(in_price*cnt)/sum(price*cnt))*100,1),'%') as profit_rate
from tb_product_info t join tb_order_overall t1 join tb_order_detail t2 on t.product_id = t2.product_id and t1.order_id = t2.order_id
where shop_id=901  and date(event_time)>='20211001'
group by t.product_id
having 1-sum(in_price*cnt)/sum(price*cnt)>0.249
order by pproduct_id) t
全部评论
请问进价为什么不是 in_price-进货价格 * quantity-进货数量,而是乘cnt-下单数量?
点赞
送花
回复
分享
发布于 2022-04-25 20:34
商品毛利率为什么要乘cnt啊
点赞
送花
回复
分享
发布于 2023-02-02 17:07 浙江
滴滴
校招火热招聘中
官网直投

相关推荐

13 1 评论
分享
牛客网
牛客企业服务