题解 | #某宝店铺动销率与售罄率#
某宝店铺动销率与售罄率
https://www.nowcoder.com/practice/715dd44c994f45cb871afa98f1b77538
select style_id,round(sum(rt1)/(sum(inventory)-sum(rt1))*100,2) pin_rate, round(sum(GMV1)/sum(tag_price*inventory)*100,2) from( select distinct st.item_id, sum(sales_num) rt1, sum(sales_price) GMV1 from sales_tb st left join product_tb pt using(item_id) group by st.item_id order by st.item_id ) as t1 left join product_tb pt using(item_id) group by style_id order by style_id ;
这题卡死在了对动销率的理解上。。
1.计算每种单品的销售量(rt1)和销售额(GMV1),得到A001,A002....C002各单品的销售量(计算动销率)和销售额(计算售罄率)
select distinct st.item_id,
sum(sales_num) rt1,
sum(sales_price) GMV1
from sales_tb st left join product_tb pt using(item_id)
group by st.item_id
order by st.item_id
2.连接product_id表计算A/B/C三种品类产品的动销率和售罄率
(1)----根据style_id分组计算
group by style_id
(2)----动销率计算:
我开始错误的理解动销率的计算公式,以为A的动销率就是sum(rt1)/sum(inventory),看评论区才理解了,
动销率=有销售的SKU数量/在售SKU数量
有销售的SKU数量:以A品类举例,A001,A002,A003总共销售的件数:sum(rt1)
在售SKU数量:A品类的总库存-已经售出的数量=sum(inventory)-sum(rt1)
(3)售罄率计算:
GMV/备货值
GMV:以A品类为例:A001,A002,A003总销售金额:sum(GMV1)
备货值:sum(tag_price*inventory)