#查询出商家的总销售金额、总退款金额、平均满意度得分。
#查询结果按照商家ID升序排列
select temp1.merchant_id,merchant_name,total_sales_amount,total_refund_amount,average_satisfaction_score
from(
    select distinct merchant_id,sum(sale_amount)  as total_sales_amount
    from sales_underline
    group by merchant_id
) as temp1
inner join(
    select distinct a.merchant_id,merchant_name,round(avg(satisfaction_score),2) as average_satisfaction_score
    from satisfaction_underline as a
    inner join merchants_underline as b
    on a.merchant_id = b.merchant_id
    group by a.merchant_id,merchant_name
) as temp2
on temp1.merchant_id = temp2.merchant_id
inner join(
    select distinct merchant_id,sum(refund_amount) as total_refund_amount
    from refunds_underline
    group by merchant_id
) as temp3
on temp2.merchant_id = temp3.merchant_id
order by temp1.merchant_id