-- 逻辑拆解:求退货率和平均客户满意度
SELECT 
    t1.brand_id,
    t1.brand_name,
    ROUND(SUM(t2.return_status)/COUNT(t2.order_id),2) return_rate_July_2024,
    ROUND(AVG(t3.customer_satisfaction_score),2) average_customer_satisfaction_score
FROM brand_info t1
LEFT JOIN sales_orders t2
ON t1.brand_id = t2.brand_id
AND t2.order_date BETWEEN '2024-07-01' AND '2024-07-31'
LEFT JOIN customer_feedback t3
ON t2.order_id = t3.order_id
GROUP BY t1.brand_id,t1.brand_name
ORDER BY t1.brand_id