+ On Mon, Dec 7, 2009 at 12:37 PM, Bruno Sales <[email protected]> wrote: > Fala galera, to me batendo aqui pra fazer uma consulta que some 2 > colunas de diferentes tabelas. > devo utilizar o sum? mesmo sabendo que cada consulta ja utiliza o sum > anteriormente: > > SELECT meso.the_geom, meso.gid, meso.nome, estab2007.estabfed2007, > estab2007.estabest2007, estab2007.estabmun2007, > estab2007.estabpriv2007, estab2007_9_anos.estabfed2007_9_anos, > estab2007_9_anos.estabest2007_9_anos, > estab2007_9_anos.estabmun2007_9_anos, > estab2007_9_anos.estabpriv2007_9_anos > FROM ( SELECT soc_estab_nfm_2007.mesoregiao, > sum(soc_estab_nfm_2007.estab_fund_fed) AS estabfed2007, > sum(soc_estab_nfm_2007.estab_fund_est) AS estabest2007, > sum(soc_estab_nfm_2007.estab_fund_mun) AS estabmun2007, > sum(soc_estab_nfm_2007.estab_fund_priv) AS estabpriv2007 > FROM social.soc_estab_nfm_2007 > GROUP BY soc_estab_nfm_2007.mesoregiao) estab2007, ( SELECT > soc_estab_nfm_2007_9_anos.mesoregiao, > sum(soc_estab_nfm_2007_9_anos.estab_fund_fed) AS estabfed2007_9_anos, > sum(soc_estab_nfm_2007_9_anos.estab_fund_est) AS estabest2007_9_anos, > sum(soc_estab_nfm_2007_9_anos.estab_fund_mun) AS estabmun2007_9_anos, > sum(soc_estab_nfm_2007_9_anos.estab_fund_priv) AS estabpriv2007_9_anos > FROM social.soc_estab_nfm_2007_9_anos > GROUP BY soc_estab_nfm_2007_9_anos.mesoregiao) > estab2007_9_anos, ( SELECT mesoregioes.the_geom, mesoregioes.gid, > mesoregioes.nome > FROM mesoregioes) meso > WHERE estab2007.mesoregiao::text = estab2007_9_anos.mesoregiao::text > AND estab2007.mesoregiao::text = meso.nome::text AND > estab2007_9_anos.mesoregiao = meso.nome::text > > > ja coloquei as tabelas listadas no select, so nao consegui soma-las ainda > > a ideia era somar estab2007 e estab_2007_9_anos > > agradeço qualquer dica > []´s > _______________________________________________ > pgbr-geral mailing list > [email protected] > https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral >
-- Gabriel Vieira _______________________________________________ pgbr-geral mailing list [email protected] https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
