select
    a.merchant_id,
    m.merchant_name,
    total_sales_amount,
    total_refund_amount,
    average_satisfaction_score
from
    (
        select
            merchant_id,
            sum(sale_amount) as total_sales_amount
        from
            sales_underline
        group by
            merchant_id
    ) a
    join (
        select
            merchant_id,
            sum(refund_amount) as total_refund_amount
        from
            refunds_underline
        group by
            merchant_id
    ) b on a.merchant_id = b.merchant_id
    join (
        select
            merchant_id,
            round(avg(satisfaction_score), 2) as average_satisfaction_score
        from
            satisfaction_underline
        group by
            merchant_id
    ) c on a.merchant_id = c.merchant_id
    join merchants_underline m on m.merchant_id = a.merchant_id
order by
    a.merchant_id

其实就是每个表求出需要的信息,然后再结合merchant_name,输出就好了。