SyntaxFix
Write A Post
Hire A Developer
Questions
It's now builtin in MySQL 8.0 and MariaDB 10.2:
SELECT itemID, COUNT(*) as ordercount, ROW_NUMBER OVER (PARTITION BY itemID ORDER BY rank DESC) as rank FROM orders GROUP BY itemID ORDER BY rank DESC