题解 | #某宝店铺动销率与售罄率#
某宝店铺动销率与售罄率
https://www.nowcoder.com/practice/715dd44c994f45cb871afa98f1b77538
select substr(t1.item_id,1,1) style_id, round(sum(t1.total_sale) / sum(t2.total_invent - t1.total_sale ) * 100, 2), round(sum(t1.sale_price) / sum(t2.total_price) * 100, 2) from (select s.item_id , sum(s.sales_num) total_sale, sum(s.sales_price) sale_price from sales_tb s group by s.item_id) as t1 left join (select p.item_id, sum(p.inventory) total_invent, sum(p.tag_price * p.inventory) total_price from product_tb p group by p.item_id) as t2 on t1.item_id = t2.item_id group by style_id