题解 | 了解 2023 年全年所有商品的盈利情况
了解 2023 年全年所有商品的盈利情况
https://www.nowcoder.com/practice/05cbbb8662c14b46a15cbcb8993d9277
select product_id, sum(total_profit) as total_profit, round(avg(profit_margin),2) as profit_margin from ( select product_id, quantity*(unit_price-purchase_price) as total_profit, (unit_price-purchase_price)/purchase_price*100 as profit_margin from sales_orders join purchase_prices using(product_id)) u group by product_id order by product_id
网易游戏公司福利 606人发布