select
order_num,sum(item_price * quantity) total_price
from OrderItems
groupby order_num
having total_price >=1000
第二步: 将Customers表与Orders表进行内连接,之后再与第一步得到的新表进行内连接
selectfrom
Customers c innerjoin Orders o
on c.cust_id = o.cust_id innerjoin(select
order_num,sum(item_price * quantity) total_price
from OrderItems
groupby order_num
having total_price >=1000) oi
on o.order_num = oi.order_num
orderby oi.order_num