Tag et kig på dette .
Skift din forespørgsel til:
SET @rank=0;
SELECT @rank:[email protected]+1 AS rank, itemID, COUNT(*) as ordercount
FROM orders
GROUP BY itemID
ORDER BY ordercount DESC;
SELECT @rank;
Det sidste valg er dit antal.
Tag et kig på dette .
Skift din forespørgsel til:
SET @rank=0;
SELECT @rank:[email protected]+1 AS rank, itemID, COUNT(*) as ordercount
FROM orders
GROUP BY itemID
ORDER BY ordercount DESC;
SELECT @rank;
Det sidste valg er dit antal.