You can use group by
as follows:
select i.agency, count(distinct m.id) meters
from installation i
join meter m on m.installation_id = i.id
join repository rp on rp.id = m.repository_id
join reading r on r.repository_number = rp.number
group by i.agency;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…