题解 | #某宝店铺折扣率#
某宝店铺折扣率
https://www.nowcoder.com/practice/3a56f160308441f5a79d8ac8d953e5e7
#需求:统计折扣率 #要求:折扣率=成交金额/(标签价格*销售数量),输出保留两位小数 #特殊点:输出数据表头discount_rate(%),有带括号,直接as会错误识别,要单独'';输出的数据虽然不带%,但是百分比类型,需要乘以100 select round(sum(sales_price)/sum(tag_price*sales_num)*100,2) 'discount_rate(%)' from sales_tb t1 left join product_tb t2 using(item_id)
