考察了基础知识
了解 2023 年全年所有商品的盈利情况
https://www.nowcoder.com/practice/05cbbb8662c14b46a15cbcb8993d9277
select
so.product_id,
sum((unit_price - purchase_price) * quantity) as total_profit,
round((avg(unit_price)-purchase_price)/purchase_price * 100,2) as profit_margin
from
sales_orders as so
left join
purchase_prices as pp on so.product_id = pp.product_id
where
order_date like "2023%"
group by so.product_id
order by product_id asc
查看12道真题和解析