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

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

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

with a as (
select t1.product_id,in_price*cnt ipcn,price*cnt pcn
from tb_order_detail t3 left join tb_product_info t1
on t3.product_id = t1.product_id
left join tb_order_overall t2
on  t3.order_id = t2.order_id
where date(event_time) >='2021-10-01'
and shop_id = 901
)
select '店铺汇总' product_id, concat(round(100*(1-sum(ipcn)/sum(pcn)),1),'%') profit_rat
from a
union
(select product_id,concat(profit_rat,'%') profit_rate from
(select product_id,round(100*(1-sum(ipcn)/sum(pcn)),1) profit_rat
from a
group by product_id) b
where profit_rat >24.9
order by profit_rat);

全部评论

相关推荐

今年读完研的我无房无车无对象,月入还没有过万 看到他在朋友圈晒房产证,感叹自己白读了这么多年书
小浪_Coding:学历不代表就能赚多少钱, 自己硕士学历怎么说也是一方面好事, 工作只是为了谋生, 赚钱跟学历不挂钩, 看自己走什么样的路,做什么选择
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务