题解 | #某宝店铺动销率与售罄率#
某宝店铺动销率与售罄率
http://www.nowcoder.com/practice/715dd44c994f45cb871afa98f1b77538
注意审题,尤其是题目中动销率(pin_rate,有销售的SKU数量/在售SKU数量)与售罄率(sell-through_rate,GMV/备货值,备货值=吊牌价*库存数)的定义。
select t1.style_id,
round(sum(t2.sales) / (sum(t1.inventory) - sum(t2.sales)) * 100, 2),
round(sum(t2.gmv) / sum(t1.inventory * t1.tag_price) * 100, 2)
from product_tb t1
left join
(
select item_id,
sum(sales_num) sales,
sum(sales_price) gmv
from sales_tb
group by 1
) t2
on t1.item_id = t2.item_id
group by 1
order by 1 asc