For the following query:
SELECT l.*
FROM `leads` AS `l`
INNER JOIN `users` AS `u` ON l.client_id = u.id
WHERE (`l`.`lender_id` = 1)
AND (l.claimed_date IS NULL)
AND (`l`.`disabled` = 0)
AND (u.last_activity_date > '2012-01-13 02:42:10')
AND (l.id = (
SELECT `leads`.`id`
FROM `leads`
WHERE (lender_id = l.lender_id)
AND (client_id = l.client_id)
AND (disabled = 0)
ORDER BY `price` DESC
LIMIT 0, 1
))
GROUP BY `l`.`client_id`
ORDER BY `u`.`last_activity_date` DESC
How could we restructure the query to remove the correlated subquery?