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

京公网安备 11010502036488号