题解 | #确定最佳顾客的另一种方式(二)#
确定最佳顾客的另一种方式(二)
http://www.nowcoder.com/practice/b5766f970ae64ac7944f37f5b47107aa
SELECT cust_name, total_price
FROM
(
SELECT order_num, SUM(item_price * quantity) AS total_price
FROM OrderItems
GROUP BY order_num
HAVING total_price >= 1000
) a
INNER JOIN Orders ON a.order_num = Orders.order_num
INNER JOIN Customers ON Orders.cust_id = Customers.cust_id
order by total_price