题解 | 哪些产品在特定时间段内表现最为出色

哪些产品在特定时间段内表现最为出色

https://www.nowcoder.com/practice/866a4614615b43a29750537ede4bf0c8

with temp as
(
    select
                product_id,
                product_name,
                sum(sales_amount) as total_sales_amount,
                sum(sales_quantity) as total_sales_quantity
            from
                sales_records
                join products using (product_id)
            where
                year(sales_date) = 2024
            group by
                product_id
            order by total_sales_amount desc ,product_id asc
)

select
    product_id,
    product_name,
     total_sales_amount,
    total_sales_quantity
    from temp   
    where total_sales_quantity=(select max(total_sales_quantity) from temp)
            

全部评论

相关推荐

鲸鸿:实习协议不用管签多久,要走的时候提前三天说就可以了
点赞 评论 收藏
分享
合适才能收到offe...:些许风霜罢了查看图片
点赞 评论 收藏
分享
评论
4
收藏
分享

创作者周榜

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