select
p.product_id,
p.product_name,
round(p.price*s.sum_quantity,2) as total_sales
from products_underline p
join
(select
product_id,sum(quantity) as sum_quantity
from sales_underline
where sale_month between '2024-01' and '2024-06'
group by product_id) s
on p.product_id=s.product_id
order by 1;



京公网安备 11010502036488号