题解 | 电商平台需要对商家的销售业绩、退款情况和客户满意度进行综合评估
电商平台需要对商家的销售业绩、退款情况和客户满意度进行综合评估
https://www.nowcoder.com/practice/48a236567617449eb6010274b30b29e8
SELECT a.merchant_id,
a.merchant_name,
b.total_sales_amount,
c.total_refund_amount,
d.average_satisfaction_score
FROM merchants_underline AS a
LEFT JOIN (
SELECT merchant_id, SUM(sale_amount) AS total_sales_amount
FROM sales_underline
GROUP BY merchant_id
) AS b
ON a.merchant_id = b.merchant_id
LEFT JOIN (
SELECT merchant_id, SUM(refund_amount) AS total_refund_amount
FROM refunds_underline
GROUP BY merchant_id
) AS c
ON b.merchant_id = c.merchant_id
LEFT JOIN (
SELECT merchant_id,
ROUND(AVG(satisfaction_score), 2) AS average_satisfaction_score
FROM satisfaction_underline
GROUP BY merchant_id
) AS d
ON c.merchant_id = d.merchant_id
ORDER BY merchant_id;
查看15道真题和解析