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

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

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

with t1 as (
select product_id, price, cnt, in_price
from tb_order_detail
join tb_product_info using(product_id)
join tb_order_overall using(order_id)
where shop_id=901 and date(event_time)>='2021-10-01'), t2 as (

select ifnull(product_id,'店铺汇总') as product_id,
    round(100*(1-sum(in_price*cnt)/sum(price*cnt)),1) profit_rate
from t1
group by product_id
with rollup
having round(100*(1-sum(in_price*cnt)/sum(price*cnt)),1) >24.9 or product_id is null
order by product_id)

select product_id, concat(profit_rate, '%') profit_rate
from t2

全部评论

相关推荐

湫湫湫不会java:1.在校经历全删了2.。这些荣誉其实也没啥用只能说,要的是好的开发者不是好好学生3.项目五六点就行了,一个亮点一俩行,xxx技术解决,xxx问题带来xxx提升。第一页学历不行,然后啥有价值的信息也没有,到第二页看到项目了,第一个项目九点,第二个项目像凑数的俩点。总体给人又臭又长,一起加油吧兄弟
点赞 评论 收藏
分享
头顶尖尖的程序员:我也是面了三四次才放平心态的。准备好自我介绍,不一定要背熟,可以记事本写下来读。全程控制语速,所有问题都先思考几秒,不要急着答,不要打断面试官说话。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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