Advertisement
jzgeorge

ASASASDAS

Apr 28th, 2017
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. -- DROP VIEW esq_ceac_planclase.v_syllabus_materia_departamento;
  2.  
  3. CREATE OR REPLACE VIEW esq_ceac_planclase.v_syllabus_materia_departamento AS
  4. SELECT row_number() OVER ()::numeric AS idregistro,
  5. tbl_syllabus.idregistro AS idsyllabus,
  6. tbl_syllabus.id_materia,
  7. tbl_syllabus.id_periodo_academico,
  8. tbl_syllabus.codigo,
  9. tbl_syllabus.tipo_materia,
  10. tbl_syllabus.estado,
  11. concat(tbl_syllabus_docente_informacion.apellido1, ' ', tbl_syllabus_docente_informacion.apellido2, ' ', tbl_syllabus_docente_informacion.nombres) AS nombredocente,
  12. tbl_syllabus_docente_informacion.email_institucional,
  13. materia_unica.iddepartamento,
  14. materia_unica.nombre AS nombreasignatura,
  15. departamento.nombre AS nombredepartamento,
  16. periodo_academico.nombre AS nombreperiodo,
  17. tbl_syllabus.fecha_creacion,
  18. tbl_syllabus.tipo_syllabus,
  19. tbl_syllabus.id_personal_aprueba,
  20. CASE
  21. WHEN tbl_syllabus.tipo_materia = 'CG'::text THEN ( SELECT tbl_syllabus_mu_departamentos.fecha_aprobacion
  22. FROM esq_ceac_planclase.tbl_syllabus_mu_departamentos
  23. WHERE tbl_syllabus_mu_departamentos.id_syllabus = tbl_syllabus.idregistro
  24. LIMIT 1)
  25. ELSE ( SELECT tbl_syllabus_mallas.fecha_aprobacion
  26. FROM esq_ceac_planclase.tbl_syllabus_mallas
  27. WHERE tbl_syllabus_mallas.id_syllabus = tbl_syllabus.idregistro AND tbl_syllabus_mallas.aprueba = 'S'::text
  28. LIMIT 1)
  29. END AS fecha_aprobacion
  30. FROM esq_ceac_planclase.tbl_syllabus
  31. JOIN esq_ceac_planclase.tbl_syllabus_docente_informacion ON tbl_syllabus.idregistro = tbl_syllabus_docente_informacion.id_syllabus
  32. JOIN esq_distributivos.materia_unica ON tbl_syllabus.id_materia = materia_unica.idmateria_unica
  33. JOIN esq_distributivos.departamento ON materia_unica.iddepartamento = departamento.iddepartamento
  34. JOIN esq_periodos_academicos.periodo_academico ON tbl_syllabus.id_periodo_academico = periodo_academico.idperiodo;
  35.  
  36. ALTER TABLE esq_ceac_planclase.v_syllabus_materia_departamento
  37. OWNER TO ceac_analitico;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement