题解 | 查询出每个品牌在特定时间段内的退货率以及平均客户满意度评分
查询出每个品牌在特定时间段内的退货率以及平均客户满意度评分
https://www.nowcoder.com/practice/39f4ccb8ac1b47a89d092b4d8ed08bc8
with t1 as (
select order_id,brand_id,order_date,return_status
from sales_orders
where month(order_date) = 7
)
select b.brand_id,brand_name,
round(sum(return_status)/count(return_status),2) return_rate_July_2024,
round(avg(customer_satisfaction_score),2) average_customer_satisfaction_score
from brand_info b join t1 on b.brand_id = t1.brand_id
join customer_feedback c on t1.order_id = c.order_id
group by b.brand_id
order by b.brand_id
