Advertisement
jzgeorge

XXX

May 5th, 2017
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1. DROP VIEW esq_ceac_planclase.v_syllabus;
  2.  
  3. CREATE OR REPLACE VIEW esq_ceac_planclase.v_syllabus 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.id_programa_analitico,
  10. tbl_syllabus.tipo_materia,
  11. tbl_syllabus.tipo_syllabus,
  12. tbl_syllabus.fecha_creacion,
  13. tbl_syllabus.id_personal_aprueba,
  14. tbl_syllabus.estado,
  15. tbl_syllabus.creditos,
  16. tbl_syllabus_docente_informacion.id_personal,
  17. (SELECT personal.apellido1|| ' ' ||personal.apellido2 || ' ' || personal.nombres from esq_datos_personales.personal where personal.idpersonal = tbl_syllabus.id_personal_aprueba ) as nombreaprueba,
  18. tbl_syllabus_docente_informacion.email_institucional,
  19. esq_ceac_planclase.tbl_syllabus_docente_informacion.titulo_cuarto_nivel,
  20. tbl_syllabus_mallas.id_malla,
  21. tbl_syllabus_mallas.id_escuela,
  22. escuela.nombre AS nombreescuela,
  23. materia_unica.nombre AS nombremateria,
  24. malla_escuela.nombre AS nombremalla,
  25. materia_unica.iddepartamento,
  26. departamento.nombre as nombredepartamento,
  27. CASE
  28. WHEN tbl_syllabus.tipo_materia = 'CG'::text THEN ( SELECT tbl_syllabus_mu_departamentos.fecha_aprobacion
  29. FROM esq_ceac_planclase.tbl_syllabus_mu_departamentos
  30. WHERE tbl_syllabus_mu_departamentos.id_syllabus = tbl_syllabus.idregistro
  31. LIMIT 1)
  32. ELSE ( SELECT tbl_syllabus_mallas.fecha_aprobacion
  33. FROM esq_ceac_planclase.tbl_syllabus_mallas
  34. WHERE tbl_syllabus_mallas.id_syllabus = tbl_syllabus.idregistro AND tbl_syllabus_mallas.aprueba = 'S'::text
  35. LIMIT 1)
  36. END AS fecha_aprobacion,
  37. concat(tbl_syllabus_docente_informacion.apellido1, ' ', tbl_syllabus_docente_informacion.apellido2, ' ', tbl_syllabus_docente_informacion.nombres) AS nombre_docente,
  38. ( SELECT array_to_string(array_agg(concat(bbl.autor, ', ', bbl.titulo, ', ', bbl.anio, '.')), '|<BR>'::text) AS bibliografia_b
  39. FROM esq_ceac_planclase.tbl_programas_bibliografias bbl
  40. WHERE bbl.idprograma = tbl_syllabus.id_programa_analitico AND bbl.tipo ~~ '%B%'::text) AS bibliografia_b,
  41. ( SELECT array_to_string(array_agg(concat(bbl.autor, ', ', bbl.titulo, ', ', bbl.anio, '.')), '|<BR>'::text) AS bibliografia_c
  42. FROM esq_ceac_planclase.tbl_programas_bibliografias bbl
  43. WHERE bbl.idprograma = tbl_syllabus.id_programa_analitico AND bbl.tipo ~~ '%C%'::text) AS bibliografia_c
  44. FROM esq_ceac_planclase.tbl_syllabus
  45. JOIN esq_ceac_planclase.tbl_syllabus_docente_informacion ON tbl_syllabus.idregistro = tbl_syllabus_docente_informacion.id_syllabus
  46. LEFT JOIN esq_ceac_planclase.tbl_syllabus_mallas ON tbl_syllabus.idregistro = tbl_syllabus_mallas.id_syllabus
  47. left JOIN esq_ceac_planclase.tbl_syllabus_mu_departamentos ON tbl_syllabus.idregistro = tbl_syllabus_mu_departamentos.id_syllabus
  48. LEFT JOIN esq_inscripciones.escuela ON tbl_syllabus_mallas.id_escuela = escuela.idescuela
  49. LEFT JOIN esq_distributivos.materia_unica ON tbl_syllabus.id_materia = materia_unica.idmateria_unica
  50. LEFT JOIN esq_mallas.malla_escuela ON tbl_syllabus_mallas.id_malla = malla_escuela.idmalla
  51. LEFT JOIN esq_distributivos.departamento ON materia_unica.iddepartamento = departamento.iddepartamento;
  52.  
  53. ALTER TABLE esq_ceac_planclase.v_syllabus
  54. OWNER TO ceac_analitico;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement