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