diff --git a/Unify_States.sql b/Unify_States.sql new file mode 100644 index 0000000000000000000000000000000000000000..0266fff143ee9017d77689c76b1f5c8ea3ee62d9 --- /dev/null +++ b/Unify_States.sql @@ -0,0 +1,38 @@ +-- +--Copyright (C) 2019 Centro de Computacao Cientifica e Software Livre +--Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR +-- +--This file is part of SMPPIR-Tables. +-- +--SMPPIR-Tables is free software: you can redistribute it and/or modify +--it under the terms of the GNU General Public License as published by +--the Free Software Foundation, either version 3 of the License, or +--(at your option) any later version. +-- +--SMPPIR-Tables is distributed in the hope that it will be useful, +--but WITHOUT ANY WARRANTY; without even the implied warranty of +--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +--GNU General Public License for more details. +-- +--You should have received a copy of the GNU General Public License +--along with SMPPIR-Tables. If not, see <https://www.gnu.org/licenses/>. +-- + + +CREATE TABLE Brasil AS +SELECT + regiao.id AS regiao_id, + regiao.nome AS nome_regiao, + estado.id AS estado_id, + estado.nome AS nome_estado, + estado.sigla AS sigla_estado, + municipio.id AS municipio_id, + municipio.nome AS nome_municipio +FROM + regiao, + estado, + municipio +WHERE + regiao.id = estado.regiao_id AND + estado.id = municipio.estado_id +; \ No newline at end of file diff --git a/esf_quilombolas.sql b/esf_quilombolas.sql new file mode 100644 index 0000000000000000000000000000000000000000..a96f767de52ae9e6aac100b8acc084413ef389bb --- /dev/null +++ b/esf_quilombolas.sql @@ -0,0 +1,45 @@ +-- +--Copyright (C) 2019 Centro de Computacao Cientifica e Software Livre +--Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR +-- +--This file is part of SMPPIR-Tables. +-- +--SMPPIR-Tables is free software: you can redistribute it and/or modify +--it under the terms of the GNU General Public License as published by +--the Free Software Foundation, either version 3 of the License, or +--(at your option) any later version. +-- +--SMPPIR-Tables is distributed in the hope that it will be useful, +--but WITHOUT ANY WARRANTY; without even the implied warranty of +--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +--GNU General Public License for more details. +-- +--You should have received a copy of the GNU General Public License +--along with SMPPIR-Tables. If not, see <https://www.gnu.org/licenses/>. +-- + +CREATE TABLE esf_quilombolas AS +SELECT + brasil.municipio_id AS municipio_id, + brasil.nome_municipio AS nome_municipio, + brasil.estado_id AS estado_id, + brasil.sigla_estado AS sigla_estado, + brasil.nome_estado AS nome_estado, + brasil.regiao_id AS regiao_id, + brasil.nome_regiao AS nome_regiao, + equipes_saude.cod_municipio AS id_municipio_equipes, + equipes_saude.no_referencia AS nome_equipe, + equipes_saude.ano_censo AS ano_censo +FROM + (SELECT municipio_id AS id, (municipio_id / 10) AS id_6 FROM brasil) AS novo_id, + equipes_saude, + brasil +WHERE + novo_id.id = brasil.municipio_id AND + equipes_saude.cod_municipio = novo_id.id_6 AND + equipes_saude.tp_pop_assist_quilomb = 1 +ORDER BY + equipes_saude.ano_censo, + brasil.regiao_id, + brasil.estado_id +; \ No newline at end of file