select c.cust_name, A.total_price from Customers c inner join (select o.cust_id, sum(oi.item_price*quantity*1.000) total_price from OrderItems oi inner join Orders o on oi.order_num = o.order_num group by o.cust_id ) A on A.cust_id = c.cust_id where A.total_price >= 1000 order by A.total_price #数据每一行都能互相匹配,所以连接方式对结果并没有什么影响