/*使用连接+分组查询*/ select cust_name, sum(item_price*quantity) total_price from OrderItems oi join Orders o on oi.order_num=o.order_num join Customers c on c.cust_id=o.cust_id group by cust_name having sum(item_price*quantity)>1000 # 注意一般来说,不建议在having后面使用别名(从执行顺序上说) order by total_price; # order by 后面可以使用别名