2010-08-15 15 views
7

tavolo assomiglia a questo:SELECT DISTINCT e contare

tag | entryID 
----+--------- 
foo | 1 
foo | 2 
bar | 3 

e ora voglio per ottenere tutti i tag con il suo utilizzo:

foo | 2 
bar | 1 

Come posso fare questo?

Grazie

risposta

22
select tag, count(*) 
from MyTable 
group by tag 
+1

Va bene, io non avrei saltato il raggruppamento-parte nel tutorial .. grazie – jake

+0

ha funzionato per me molto bene – humphrey

Problemi correlati