题解 | 电商平台想要查询出每个商品在 2024 年上半年(1 月至 6 月)的总销售额

电商平台想要查询出每个商品在 2024 年上半年(1 月至 6 月)的总销售额

https://www.nowcoder.com/practice/e190c019dabe4622ae719cca64437a47

select a.product_id, product_name, sum(price*quantity) as total_sales
from products_underline a
join (
    select *
    from sales_underline
    where left(sale_month, 4)=2024 and right(sale_month, 2) in (1, 2, 3, 4, 5, 6)
) b on a.product_id=b.product_id
group by a.product_id, product_name
order by a.product_id

全部评论

相关推荐

不知道怎么取名字_:现在找工作是真的太不容易了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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