我需要以下 MySQL 查询方面的帮助
我想在没有任何子查询的情况下重写我的查询 - 但我不知道如何..
它是一个视频租赁商店数据库;)
SELECT k.first_name, k.last_name, SUM(amount) AS profit
FROM payment AS p
JOIN (SELECT c.* FROM customer AS c
JOIN rental AS r ON c.customer_id = r.customer_id
WHERE r.return_date IS NULL GROUP BY c.customer_id HAVING
COUNT(*) > '1') AS k ON p.customer_id = k.customer_id
GROUP BY k.customer_id
HAVING SUM(amount) > 100
ORDER BY profit DESC;
谢谢 :)