题解 | #某宝店铺折扣率#
某宝店铺动销率与售罄率
http://www.nowcoder.com/practice/715dd44c994f45cb871afa98f1b77538
with sales_group as ( select style_id, sum(sales_price) as s, sum(sales_num) as sn from sales_tb x join product_tb y on x.item_id = y.item_id group by 1 ), pro_group as ( select style_id, sum(tag_price * inventory) as t, sum(inventory) as inv from product_tb group by 1 ) select aaa.style_id, round(100 * sn / (inv - sn), 2), round(100 * s / t, 2) from sales_group aaa join pro_group bbb on aaa.style_id = bbb.style_id group by 1