Skip to content

Commit

Permalink
Adiciona schema em views
Browse files Browse the repository at this point in the history
  • Loading branch information
edersoares committed Jan 20, 2020
1 parent 5c65b4e commit f1e3134
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ CREATE OR REPLACE VIEW relatorio.view_historico_9anos AS
(historico_por_disciplina.dependencia OPERATOR(relatorio.->) (((historico_disciplinas.disciplina || '-'::text) || '9'::text) || '-dependencia'::text))::boolean AS disciplina_dependencia9,
(
SELECT m.cod_matricula
FROM matricula m
FROM pmieducar.matricula m
WHERE m.ano = (
(
SELECT max(he.ano) AS max
FROM historico_escolar he
FROM pmieducar.historico_escolar he
WHERE he.ref_cod_aluno = historico_disciplinas.ref_ref_cod_aluno
AND he.ativo = 1
AND he.extra_curricular = 0
Expand All @@ -186,7 +186,7 @@ CREATE OR REPLACE VIEW relatorio.view_historico_9anos AS
SELECT textcat_all(tabl.obs) AS textcat_all
FROM (
SELECT phe.observacao AS obs
FROM historico_escolar phe
FROM pmieducar.historico_escolar phe
WHERE phe.ref_cod_aluno = historico_disciplinas.ref_ref_cod_aluno
AND phe.ativo = 1
AND phe.extra_curricular = 0
Expand All @@ -195,7 +195,7 @@ CREATE OR REPLACE VIEW relatorio.view_historico_9anos AS
ORDER BY phe.ano
) tabl
) AS observacao_all
FROM historico_escolar
FROM pmieducar.historico_escolar
JOIN LATERAL (
SELECT
historico_disciplinas_1.sequencial,
Expand All @@ -204,7 +204,7 @@ CREATE OR REPLACE VIEW relatorio.view_historico_9anos AS
btrim(relatorio.get_texto_sem_caracter_especial(historico_disciplinas_1.nm_disciplina::character varying)::text) AS disciplina,
historico_disciplinas_1.nota,
historico_disciplinas_1.faltas
FROM historico_disciplinas historico_disciplinas_1
FROM pmieducar.historico_disciplinas historico_disciplinas_1
) historico_disciplinas ON historico_escolar.ref_cod_aluno = historico_disciplinas.ref_ref_cod_aluno AND historico_escolar.sequencial = historico_disciplinas.ref_sequencial
JOIN LATERAL (
SELECT
Expand Down Expand Up @@ -285,7 +285,7 @@ CREATE OR REPLACE VIEW relatorio.view_historico_9anos AS
historico_disciplinas_1.dependencia::text AS dependencia_value,
historico_disciplinas_1.disciplina,
historico_escolar_1.ref_cod_aluno
FROM historico_escolar historico_escolar_1
FROM pmieducar.historico_escolar historico_escolar_1
JOIN LATERAL (
SELECT
historico_disciplinas_2.sequencial,
Expand All @@ -296,7 +296,7 @@ CREATE OR REPLACE VIEW relatorio.view_historico_9anos AS
historico_disciplinas_2.faltas,
historico_disciplinas_2.carga_horaria_disciplina,
historico_disciplinas_2.dependencia
FROM historico_disciplinas historico_disciplinas_2
FROM pmieducar.historico_disciplinas historico_disciplinas_2
) historico_disciplinas_1 ON historico_escolar_1.ref_cod_aluno = historico_disciplinas_1.ref_ref_cod_aluno AND historico_escolar_1.sequencial = historico_disciplinas_1.ref_sequencial
WHERE historico_escolar_1.extra_curricular = 0
AND historico_escolar_1.ativo = 1
Expand All @@ -306,7 +306,7 @@ CREATE OR REPLACE VIEW relatorio.view_historico_9anos AS
AND historico_escolar_1.sequencial = (
(
SELECT hee.sequencial
FROM historico_escolar hee
FROM pmieducar.historico_escolar hee
WHERE "substring"(hee.nm_serie::text, 1, 1) = "substring"(historico_escolar_1.nm_serie::text, 1, 1)
AND hee.ref_cod_aluno = historico_escolar_1.ref_cod_aluno
AND hee.extra_curricular = 0
Expand Down Expand Up @@ -369,4 +369,4 @@ CREATE OR REPLACE VIEW relatorio.view_historico_9anos AS
historico_por_disciplina.faltas,
historico_por_disciplina.carga_horaria_disciplina,
historico_por_disciplina.dependencia
ORDER BY ordenamento, historico_disciplinas.disciplina;
ORDER BY ordenamento, historico_disciplinas.disciplina;
18 changes: 9 additions & 9 deletions database/sqls/views/relatorio.view_historico_eja-2019-09-17.sql
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ CREATE OR REPLACE VIEW relatorio.view_historico_eja AS
(historico_por_disciplina.dependencia OPERATOR(relatorio.->) (((historico_disciplinas.disciplina || '-'::text) || '9'::text) || '-dependencia'::text))::boolean AS disciplina_dependencia9,
(
SELECT m.cod_matricula
FROM matricula m
FROM pmieducar.matricula m
WHERE m.ano = (
(
SELECT max(he.ano) AS max
FROM historico_escolar he
FROM pmieducar.historico_escolar he
WHERE he.ref_cod_aluno = historico_disciplinas.ref_ref_cod_aluno
AND he.ativo = 1
AND he.extra_curricular = 0
Expand All @@ -133,7 +133,7 @@ CREATE OR REPLACE VIEW relatorio.view_historico_eja AS
SELECT textcat_all(tabl.obs) AS textcat_all
FROM (
SELECT phe.observacao AS obs
FROM historico_escolar phe
FROM pmieducar.historico_escolar phe
WHERE phe.ref_cod_aluno = historico_disciplinas.ref_ref_cod_aluno
AND phe.ativo = 1
AND phe.extra_curricular = 0
Expand All @@ -143,7 +143,7 @@ CREATE OR REPLACE VIEW relatorio.view_historico_eja AS
ORDER BY phe.ano
) tabl
) AS observacao_all
FROM historico_escolar
FROM pmieducar.historico_escolar
JOIN LATERAL (
SELECT
historico_disciplinas_1.sequencial,
Expand All @@ -153,7 +153,7 @@ CREATE OR REPLACE VIEW relatorio.view_historico_eja AS
historico_disciplinas_1.nota,
historico_disciplinas_1.faltas,
historico_disciplinas_1.tipo_base
FROM historico_disciplinas historico_disciplinas_1
FROM pmieducar.historico_disciplinas historico_disciplinas_1
) historico_disciplinas ON historico_escolar.ref_cod_aluno = historico_disciplinas.ref_ref_cod_aluno AND historico_escolar.sequencial = historico_disciplinas.ref_sequencial
JOIN LATERAL (
SELECT
Expand Down Expand Up @@ -212,7 +212,7 @@ CREATE OR REPLACE VIEW relatorio.view_historico_eja AS
historico_disciplinas_1.dependencia::text AS dependencia_value,
historico_disciplinas_1.disciplina,
historico_escolar_1.ref_cod_aluno
FROM historico_escolar historico_escolar_1
FROM pmieducar.historico_escolar historico_escolar_1
JOIN LATERAL (
SELECT
historico_disciplinas_2.sequencial,
Expand All @@ -223,7 +223,7 @@ CREATE OR REPLACE VIEW relatorio.view_historico_eja AS
historico_disciplinas_2.faltas,
historico_disciplinas_2.carga_horaria_disciplina,
historico_disciplinas_2.dependencia
FROM historico_disciplinas historico_disciplinas_2) historico_disciplinas_1 ON historico_escolar_1.ref_cod_aluno = historico_disciplinas_1.ref_ref_cod_aluno AND historico_escolar_1.sequencial = historico_disciplinas_1.ref_sequencial
FROM pmieducar.historico_disciplinas historico_disciplinas_2) historico_disciplinas_1 ON historico_escolar_1.ref_cod_aluno = historico_disciplinas_1.ref_ref_cod_aluno AND historico_escolar_1.sequencial = historico_disciplinas_1.ref_sequencial
WHERE historico_escolar_1.extra_curricular = 0
AND historico_escolar_1.ativo = 1
AND historico_escolar_1.historico_grade_curso_id = 3
Expand All @@ -233,7 +233,7 @@ CREATE OR REPLACE VIEW relatorio.view_historico_eja AS
AND historico_escolar_1.sequencial = (
(
SELECT hee.sequencial
FROM historico_escolar hee
FROM pmieducar.historico_escolar hee
WHERE "substring"(hee.nm_serie::text, 1, 1) = "substring"(historico_escolar_1.nm_serie::text, 1, 1)
AND hee.ref_cod_aluno = historico_escolar_1.ref_cod_aluno
AND hee.extra_curricular = 0
Expand Down Expand Up @@ -287,4 +287,4 @@ GROUP BY
historico_por_disciplina.nota,
historico_por_disciplina.carga_horaria_disciplina,
historico_por_disciplina.dependencia
ORDER BY ordenamento, historico_disciplinas.disciplina;
ORDER BY ordenamento, historico_disciplinas.disciplina;
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ CREATE OR REPLACE VIEW relatorio.view_historico_eja_extra_curricular AS
(historico_por_disciplina.dependencia OPERATOR(relatorio.->) (((historico_disciplinas.disciplina || '-'::text) || '9'::text) || '-dependencia'::text))::boolean AS disciplina_dependencia9,
(
SELECT m.cod_matricula
FROM matricula m
FROM pmieducar.matricula m
WHERE m.ano = (
(
SELECT max(he.ano) AS max
FROM historico_escolar he
FROM pmieducar.historico_escolar he
WHERE he.ref_cod_aluno = historico_disciplinas.ref_ref_cod_aluno
AND he.ativo = 1
AND he.extra_curricular = 1
Expand All @@ -132,12 +132,12 @@ CREATE OR REPLACE VIEW relatorio.view_historico_eja_extra_curricular AS
SELECT textcat_all(tabl.obs) AS textcat_all
FROM (
SELECT phe.observacao AS obs
FROM historico_escolar phe
FROM pmieducar.historico_escolar phe
WHERE phe.ref_cod_aluno = historico_disciplinas.ref_ref_cod_aluno AND phe.ativo = 1 AND phe.extra_curricular = 1 AND phe.historico_grade_curso_id = 3 AND COALESCE(phe.dependencia, false) = false AND isnumeric("substring"(phe.nm_serie::text, 1, 1))
ORDER BY phe.ano
) tabl
) AS observacao_all
FROM historico_escolar
FROM pmieducar.historico_escolar
JOIN LATERAL (
SELECT
historico_disciplinas_1.sequencial,
Expand All @@ -146,7 +146,7 @@ CREATE OR REPLACE VIEW relatorio.view_historico_eja_extra_curricular AS
btrim(relatorio.get_texto_sem_caracter_especial(historico_disciplinas_1.nm_disciplina::character varying)::text) AS disciplina,
historico_disciplinas_1.nota,
historico_disciplinas_1.faltas
FROM historico_disciplinas historico_disciplinas_1
FROM pmieducar.historico_disciplinas historico_disciplinas_1
) historico_disciplinas ON historico_escolar.ref_cod_aluno = historico_disciplinas.ref_ref_cod_aluno AND historico_escolar.sequencial = historico_disciplinas.ref_sequencial
JOIN LATERAL (
SELECT
Expand Down Expand Up @@ -205,7 +205,7 @@ CREATE OR REPLACE VIEW relatorio.view_historico_eja_extra_curricular AS
historico_disciplinas_1.dependencia::text AS dependencia_value,
historico_disciplinas_1.disciplina,
historico_escolar_1.ref_cod_aluno
FROM historico_escolar historico_escolar_1
FROM pmieducar.historico_escolar historico_escolar_1
JOIN LATERAL (
SELECT
historico_disciplinas_2.sequencial,
Expand All @@ -216,7 +216,7 @@ CREATE OR REPLACE VIEW relatorio.view_historico_eja_extra_curricular AS
historico_disciplinas_2.faltas,
historico_disciplinas_2.carga_horaria_disciplina,
historico_disciplinas_2.dependencia
FROM historico_disciplinas historico_disciplinas_2
FROM pmieducar.historico_disciplinas historico_disciplinas_2
) historico_disciplinas_1 ON historico_escolar_1.ref_cod_aluno = historico_disciplinas_1.ref_ref_cod_aluno AND historico_escolar_1.sequencial = historico_disciplinas_1.ref_sequencial
WHERE historico_escolar_1.extra_curricular = 1
AND historico_escolar_1.historico_grade_curso_id = 3
Expand All @@ -227,7 +227,7 @@ CREATE OR REPLACE VIEW relatorio.view_historico_eja_extra_curricular AS
AND historico_escolar_1.sequencial = (
(
SELECT hee.sequencial
FROM historico_escolar hee
FROM pmieducar.historico_escolar hee
WHERE "substring"(hee.nm_serie::text, 1, 1) = "substring"(historico_escolar_1.nm_serie::text, 1, 1)
AND hee.ref_cod_aluno = historico_escolar_1.ref_cod_aluno
AND hee.extra_curricular = 1
Expand Down Expand Up @@ -279,4 +279,4 @@ CREATE OR REPLACE VIEW relatorio.view_historico_eja_extra_curricular AS
historico_por_disciplina.nota,
historico_por_disciplina.carga_horaria_disciplina,
historico_por_disciplina.dependencia
ORDER BY ordenamento, historico_disciplinas.disciplina;
ORDER BY ordenamento, historico_disciplinas.disciplina;
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ CREATE OR REPLACE VIEW relatorio.view_historico_series_anos AS
(historico_por_disciplina.dependencia OPERATOR(relatorio.->) (((historico_disciplinas.disciplina || '-'::text) || '9'::text) || '-dependencia'::text))::boolean AS disciplina_dependencia9,
(
SELECT m.cod_matricula
FROM matricula m
FROM pmieducar.matricula m
WHERE m.ano = (
(
SELECT max(he.ano) AS max
FROM historico_escolar he
FROM pmieducar.historico_escolar he
WHERE he.ref_cod_aluno = historico_disciplinas.ref_ref_cod_aluno
AND he.ativo = 1
AND he.extra_curricular = 0
Expand All @@ -133,7 +133,7 @@ CREATE OR REPLACE VIEW relatorio.view_historico_series_anos AS
SELECT textcat_all(tabl.obs) AS textcat_all
FROM (
SELECT phe.observacao AS obs
FROM historico_escolar phe
FROM pmieducar.historico_escolar phe
WHERE phe.ref_cod_aluno = historico_disciplinas.ref_ref_cod_aluno
AND phe.ativo = 1
AND phe.extra_curricular = 0
Expand All @@ -142,7 +142,7 @@ CREATE OR REPLACE VIEW relatorio.view_historico_series_anos AS
ORDER BY phe.ano
) tabl
) AS observacao_all
FROM historico_escolar
FROM pmieducar.historico_escolar
JOIN LATERAL (
SELECT
historico_disciplinas_1.sequencial,
Expand All @@ -152,7 +152,7 @@ CREATE OR REPLACE VIEW relatorio.view_historico_series_anos AS
historico_disciplinas_1.nota,
historico_disciplinas_1.faltas,
historico_disciplinas_1.tipo_base
FROM historico_disciplinas historico_disciplinas_1
FROM pmieducar.historico_disciplinas historico_disciplinas_1
) historico_disciplinas ON historico_escolar.ref_cod_aluno = historico_disciplinas.ref_ref_cod_aluno AND historico_escolar.sequencial = historico_disciplinas.ref_sequencial
JOIN LATERAL (
SELECT
Expand Down Expand Up @@ -271,7 +271,7 @@ CREATE OR REPLACE VIEW relatorio.view_historico_series_anos AS
historico_disciplinas_1.dependencia::text AS dependencia_value,
historico_disciplinas_1.disciplina,
historico_escolar_1.ref_cod_aluno
FROM historico_escolar historico_escolar_1
FROM pmieducar.historico_escolar historico_escolar_1
JOIN LATERAL (
SELECT
historico_disciplinas_2.sequencial,
Expand All @@ -282,7 +282,7 @@ CREATE OR REPLACE VIEW relatorio.view_historico_series_anos AS
historico_disciplinas_2.faltas,
historico_disciplinas_2.carga_horaria_disciplina,
historico_disciplinas_2.dependencia
FROM historico_disciplinas historico_disciplinas_2
FROM pmieducar.historico_disciplinas historico_disciplinas_2
) historico_disciplinas_1 ON historico_escolar_1.ref_cod_aluno = historico_disciplinas_1.ref_ref_cod_aluno AND historico_escolar_1.sequencial = historico_disciplinas_1.ref_sequencial
WHERE historico_escolar_1.extra_curricular = 0
AND historico_escolar_1.ativo = 1
Expand All @@ -292,7 +292,7 @@ CREATE OR REPLACE VIEW relatorio.view_historico_series_anos AS
AND historico_escolar_1.sequencial = (
(
SELECT hee.sequencial
FROM historico_escolar hee
FROM pmieducar.historico_escolar hee
WHERE "substring"(hee.nm_serie::text, 1, 1) = "substring"(historico_escolar_1.nm_serie::text, 1, 1)
AND hee.ref_cod_aluno = historico_escolar_1.ref_cod_aluno
AND hee.extra_curricular = 0
Expand Down Expand Up @@ -344,4 +344,4 @@ CREATE OR REPLACE VIEW relatorio.view_historico_series_anos AS
historico_por_disciplina.nota,
historico_por_disciplina.carga_horaria_disciplina,
historico_por_disciplina.dependencia
ORDER BY ordenamento, historico_disciplinas.disciplina;
ORDER BY ordenamento, historico_disciplinas.disciplina;
Loading

0 comments on commit f1e3134

Please sign in to comment.