select
    t1.product_id
    ,product_name
    ,competitor_name
    ,total_sales_amount_of_product
    ,total_sales_amount_of_product - total_competitor_sales_amount_2023 sales_difference_with_competitor
from
(
    select
    s.product_id
    ,product_name
    ,sum(quarter_1_sales_amount) + sum(quarter_2_sales_amount) + sum(quarter_3_sales_amount) + sum(quarter_4_sales_amount) total_sales_amount_of_product
    from sales_info s
    join oppo_products_detail o on s.product_id = o.product_id
    group by 1,2
    order by 1
) t1
join competitor_analysis c on t1.product_id = c.product_id