Junior — Senior
Top 10 customers with more than five purchases
livecode
Task condition
Rewrite the ORM query into pure SQL. You need to get ten users who have more than five records in the Purchase table.
SELECT u.*
FROM User u
JOIN Purchase p ON u.id = p.user_id
GROUP BY u.id
HAVING COUNT(p.id) > 5
ORDER BY COUNT(p.id) DESC
LIMIT 10;