In alternativa:
Codice PHP:

SELECT tag
COUNT(tag) as ranking
FROM taglib
GROUP BY tag
ORDER BY ranking DESC
LIMIT 5