Advertisement
jzgeorge

Untitled

Jun 21st, 2017
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.03 KB | None | 0 0
  1. -- View: esq_ceac_planclase.v_detalle_inscripcion_plc
  2.  
  3. -- DROP VIEW esq_ceac_planclase.v_detalle_inscripcion_plc;
  4.  
  5. CREATE OR REPLACE VIEW esq_ceac_planclase.v_detalle_inscripcion_plc AS
  6. SELECT ((((pd.idinscripcion::text || pd.idperiodo::text) || p.idpersonal::text) || me.idmalla::text) || pd.idmateria::text)::numeric AS idregistro,
  7. pd.idinscripcion,
  8. pd.idperiodo,
  9. pa.nombre AS nperiodo,
  10. f.idfacultad,
  11. f.nombre AS nfacultad,
  12. pd.idescuela,
  13. e.nombre AS nescuela,
  14. p.idpersonal,
  15. COALESCE(p.apellido1, ''::character varying) AS apellido1,
  16. COALESCE(p.apellido2, ''::character varying) AS apellido2,
  17. COALESCE(p.nombres, ''::character varying) AS nombres,
  18. p.cedula,
  19. p.genero,
  20. i.idnivel AS nivel,
  21. ( SELECT pa_1.nombre
  22. FROM esq_distributivos.paralelo pa_1
  23. WHERE pa_1.idparalelo = i.idparalelo) AS paralelo,
  24. i.anulado AS inscripcion_anulada,
  25. pd.anulado,
  26. da.iddistributivo,
  27. me.idmalla,
  28. pd.idmateria,
  29. m.nombre AS nmateria_malla,
  30. da.idmateria_unica,
  31. ( SELECT
  32. CASE
  33. WHEN count(mr.idmateria) > 0 THEN count(mr.idmateria) + 1
  34. ELSE 0::bigint
  35. END AS count_1
  36. FROM esq_migracion.resum_mate_reprobadas mr
  37. WHERE mr.idmateria = pd.idmateria AND mr.idescuela = e.idescuela AND mr.idmalla = me.idmalla AND mr.idpersonal = p.idpersonal AND mr.idperiodo < pd.idperiodo) AS veces_tomada,
  38. ( SELECT mu.nombre
  39. FROM esq_distributivos.materia_unica mu
  40. WHERE mu.idmateria_unica = da.idmateria_unica) AS nmateria_unica,
  41. ( SELECT mm.creditos
  42. FROM esq_mallas.malla_materia_nivel mm
  43. WHERE mm.idmalla = pd.idmalla AND mm.idescuela = pd.idescuela AND pd.idmateria = mm.idmateria) AS creditos_asignatura,
  44. ( SELECT mm.idnivel
  45. FROM esq_mallas.malla_materia_nivel mm
  46. WHERE mm.idmalla = pd.idmalla AND mm.idescuela = pd.idescuela AND pd.idmateria = mm.idmateria) AS nivel_asignatura,
  47. ( SELECT p_1.nombre
  48. FROM esq_distributivos.paralelo p_1
  49. WHERE p_1.idparalelo = da.idparalelo) AS paralelo_asignatura,
  50. da.observacion AS observacion_paralelo,
  51. da.idpersonal AS idpersonal_docente,
  52. ( SELECT (((COALESCE(personal.apellido1, ''::character varying)::text || ' '::text) || COALESCE(personal.apellido2, ''::character varying)::text) || ' '::text) || COALESCE(personal.nombres, ''::character varying)::text AS nom
  53. FROM esq_datos_personales.personal
  54. WHERE personal.idpersonal = da.idpersonal) AS docente,
  55. me.nombre AS nmalla,
  56. pd.observacion,
  57. esq_distributivos.f_horarios_concatenar_hora(da.iddistributivo) AS f_horarios_concatenar_hora,
  58. i.creditos_tomados,
  59. i.creditos_aprobados,
  60. i.creditos_aprobados_a,
  61. ( SELECT mm.materia_virtual
  62. FROM esq_mallas.malla_materia_nivel mm
  63. WHERE mm.idmalla = pd.idmalla AND mm.idescuela = pd.idescuela AND pd.idmateria = mm.idmateria) AS es_virtual,
  64. pd.asistencia,
  65. i.num_inscripcion,
  66. pd.supletorio,
  67. i.valorinscripcion,
  68. m.idtipo_perfil_profesional
  69. FROM esq_inscripciones.inscripcion_detalle pd
  70. JOIN esq_inscripciones.inscripcion i ON i.idinscripcion = pd.idinscripcion AND i.idperiodo = pd.idperiodo AND i.idescuela = pd.idescuela AND i.idpersonal = pd.idpersonal
  71. JOIN esq_distributivos.distribucion_academica da ON da.iddistributivo = pd.iddistributivo
  72. JOIN esq_inscripciones.escuela e ON e.idescuela = pd.idescuela
  73. JOIN esq_inscripciones.facultad f ON f.idfacultad = e.idfacultad
  74. JOIN esq_datos_personales.personal p ON p.idpersonal = pd.idpersonal
  75. JOIN esq_periodos_academicos.periodo_academico pa ON pa.idperiodo = pd.idperiodo
  76. JOIN esq_mallas.materia m ON m.idmateria = pd.idmateria
  77. JOIN esq_mallas.malla_escuela me ON me.idmalla = pd.idmalla;
  78.  
  79. ALTER TABLE esq_ceac_planclase.v_detalle_inscripcion_plc
  80. OWNER TO ceac_analitico;
  81. GRANT ALL ON TABLE esq_ceac_planclase.v_detalle_inscripcion_plc TO ceac_analitico;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement