题解 | 深入分析各款产品年总销售额与竞品的年度对比

深入分析各款产品年总销售额与竞品的年度对比

https://www.nowcoder.com/practice/99cc7f1798a84645a6aca5bdfd163fdb

with
    t1 as (
        select
            product_id,
            product_name,
            sum(
                quarter_1_sales_amount + quarter_2_sales_amount + quarter_3_sales_amount + quarter_4_sales_amount
            ) as total_sales_amount_of_product
        from
            sales_info
            left join oppo_products_detail using (product_id)
        group by
            product_id,
            product_name
    )
select
    product_id,
    product_name,
    competitor_name,
    total_sales_amount_of_product,
    total_sales_amount_of_product - total_del_money as sales_difference_with_competitor
from
    t1
    left join (
        select
            product_id,
            competitor_name,
            sum(total_competitor_sales_amount_2023) as total_del_money
        from
            competitor_analysis
        group by
            product_id,
            competitor_name
    ) as t2 using (product_id)
    order by product_id asc;

全部评论

相关推荐

11-04 19:05
已编辑
东莞城市学院 单片机
不知道怎么取名字_:你这个要实习两年?哪有这么久的,感觉就是即使你毕业了,但还按实习的话,是不是不用给你缴社保公积金啥的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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