题解 | #某宝店铺动销率与售罄率#
某宝店铺动销率与售罄率
http://www.nowcoder.com/practice/715dd44c994f45cb871afa98f1b77538
select
pt.style_id,
round(sum(N.sm) * 100 / (sum(pt.inventory) - sum(N.sm)),2),
round(sum(N.p) * 100 / sum(pt.tag_price * pt.inventory), 2)
from
product_tb pt
inner join (
select
st.item_id,
sum(st.sales_price) p,
sum(st.sales_num) sm
from
sales_tb st
group by
st.item_id
) N on N.item_id = pt.item_id
group by
pt.style_id