Ciao, così dovrebbe funzionare...

codice:
SELECT COUNT(*) AS totale FROM (SELECT DISTINCT id FROM contatore);