难在题目要求指标理解。
select style_id
,round((shouchu/(cunhuo-shouchu)*100),2) 'sell-through_rate(%)'
,round(shoujia/qian*100,2) 'pin_rate(%)'
from
(select style_id,sum(tag_price*inventory) qian,sum(inventory) cunhuo from product_tb
group by style_id) a
left join
(select
sum(sales_num) shouchu,
sum(sales_price) shoujia,
left(item_id,1) item_id
from sales_tb
where sales_date like '2021-11%'
group by left(item_id,1) ) b
on left(item_id,1)=a.style_id