题解 | #某宝店铺动销率与售罄率#
某宝店铺动销率与售罄率
http://www.nowcoder.com/practice/715dd44c994f45cb871afa98f1b77538
先把order表聚一下在连接,否则同个款型有多个记录
SELECT style_id,
round(sum(sales_num)/
(sum(inventory)-sum(sales_num))*100,2),
round(100*sum(GMV)/sum(tag_price*(inventory)),2)
from
product_tb left JOIN
(select item_id,sum(sales_num) as sales_num,
sum(sales_price) as GMV from sales_tb
where month(sales_date)=11
GROUP by item_id) tmp
using(item_id)
GROUP BY style_id