题解 | 电商平台需要对商家的销售业绩、退款情况和客户满意度进行综合评估
电商平台需要对商家的销售业绩、退款情况和客户满意度进行综合评估
https://www.nowcoder.com/practice/48a236567617449eb6010274b30b29e8
with t1 as(
select s1.merchant_id,merchant_name,sum(sale_amount) sale_amount
from merchants_underline m join sales_underline s1 on m.merchant_id = s1.merchant_id
group by s1.merchant_id
),
t2 as (
select merchant_id,sum(refund_amount) total_refund_amount from refunds_underline
group by merchant_id
),
t3 as (
select merchant_id,round(avg(satisfaction_score),2) average_satisfaction_score from satisfaction_underline
group by merchant_id
)
select t1.merchant_id,merchant_name,t1.sale_amount total_sales_amount,t2.total_refund_amount,t3.average_satisfaction_score
from t1 join t2 on t1.merchant_id = t2.merchant_id join t3 on t1.merchant_id = t3.merchant_id
