codice:
select count(id_record) as tot
from tabella 
group by id_valore 
order by tot desc