题解 | #某宝店铺动销率与售罄率#
某宝店铺动销率与售罄率
http://www.nowcoder.com/practice/715dd44c994f45cb871afa98f1b77538
这个题目有问题啊,正常动销率不是这么算的 with a as (select s.item_id,s.sales_num,s.sales_price,p.style_id from (select * from sales_tb)s left join (select * from product_tb)p on s.item_id=p.item_id)
select t1.style_id ,round((sold_num/(total_num-sold_num))*100,2),round((GMV/cost)100,2) from (select style_id, sum(inventory) total_num from product_tb group by style_id)t1 left join (select style_id,sum(sales_num) sold_num from a group by style_id)t2 on t1.style_id=t2.style_id left join (select style_id,sum(sales_price) GMV from a group by style_id)t3 on t1.style_id=t3.style_id left join (select style_id,sum(tag_priceinventory) cost from product_tb group by style_id)t4 on t1.style_id=t4.style_id order by t1.style_id