Brug COUNT
funktion og GROUP BY
for at finde antallet af besøg for hvert tag
.
Og brug ORDER BY
klausul for at sortere resultatet i faldende antal besøg.
Forespørgsel
SELECT tag, COUNT(DISTINCT station) AS `no of visits`
FROM taps
GROUP BY tag
ORDER BY COUNT(DISTINCT station) DESC;