题解 | #某宝店铺折扣率#
某宝店铺折扣率
http://www.nowcoder.com/practice/3a56f160308441f5a79d8ac8d953e5e7
SELECT ROUND(SUM(sales_price) / SUM(t_tag_price) * 100, 2) AS 'discount_rate(%)'
FROM (
SELECT item_id,
sales_num * tag_price AS t_tag_price,
sales_price
FROM sales_tb
JOIN product_tb
USING(item_id)
)total_price_t