题解 | 每个商品的销售总额

每个商品的销售总额

https://www.nowcoder.com/practice/6d796e885ee44a9cb599f47b16a02ea4

select c.product_name,total_sales,category_rank
from(
select b.product_name as 'product_name',total_sales,category_row,row_number() over(partition by category_row order by total_sales desc) as category_rank
from(
select product_name,total_sales,substr(category,10,1) as category_row
from(
select orders.product_id,name as product_name,category,sum(quantity) as total_sales
from orders
left join products
on products.product_id=orders.product_id
group by orders.product_id
having product_name is not null) a   # 有product_name中productE没有被记录的情况
order by a.category asc,total_sales desc,product_id asc) b) c

全部评论

相关推荐

简历求拷打,海投简历发过去就已读不回了求大佬们指点
程序员牛肉:基本不能了,估计你得放弃秋招,九月份找实习之后明年的春招开始正式找工作
点赞 评论 收藏
分享
喜欢飞来飞去的雪碧在刷代码:可以试一试字节
点赞 评论 收藏
分享
05-29 22:11
门头沟学院 Java
Elastic90:抛开学历造假不谈,这公司的招聘需求也挺怪的,Java开发还要求你有图文识别、移动端开发和c++的经验,有点逆天了。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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