SyntaxFix
Write A Post
Hire A Developer
Questions
SELECT @rn:=@rn+1 AS rank, itemID, ordercount FROM ( SELECT itemID, COUNT(*) AS ordercount FROM orders GROUP BY itemID ORDER BY ordercount DESC ) t1, (SELECT @rn:=0) t2;