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