select style_id,
round(sum(item_sum)/sum(inventory-item_sum)*100,2) as pin_rate,
round(sum(sales_price_sum)/sum(tag_price*inventory)*100,2) as sell_through_rate
#select * ##习惯这样查看一下数据结构
from product_tb
left join (select item_id,
sum(sales_price) as sales_price_sum,
sum(sales_num) as item_sum
from sales_tb
group by item_id) as t1 using(item_id)
group by style_id
order by style_id