How to select fields using alias name?
You quoted your column aliases:

SELECT 
tb_dim_equipe.no_equipe "EQUIPE", 
tb_dim_profissional.no_profissional "PROFISSIONAL", 
no_cidadao "CIDADÃO", 
a.nu_cns "CNS", 
sum(...) as "TOTAL" 


Postgres, unlike standard-compliant SQL databases, normalizes unquoted identifiers by converting them to lower case, such that the reference to c.TOTAL is equivalent to c.total. However, quoted identifiers like as "TOTAL" are not normalized and remain known to Postgres exactly as they are written.

You should either drop quotes in aliases (which I would recommend):

SELECT 
tb_dim_equipe.no_equipe AS equipe, 
tb_dim_profissional.no_profissional AS professional, 
no_cidadao AS cidadao, 
a.nu_cns AS cns, 
sum(...) AS total


or always reference quoted identifiers as quoted identifiers:

SELECT sum(c."TOTAL") from ... AS c