Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.71 KB | None | 0 0
  1. -- 2 - For each admission, show the type, date, procedence service, duration, and the average duration of the admissions of its same procedence.
  2. SELECT S.servicio_procedencia, G.tipo, P.sexo, T.fecha, F.duracion
  3.  , avg(duracion) over (partition by servicio_procedencia)
  4. from dw_ingresos.dw_fact_ingreso F,
  5.     dw_ingresos.dw_dim_proc S,
  6.     dw_ingresos.dw_dim_tipoingreso G,
  7.     dw_ingresos.dw_dim_paciente P,
  8.     dw_ingresos.dw_dim_time T
  9. where F.fk_procedencia=S.pk_procedencia         -- REUNIENDO FACT CON PROCEDENCIA
  10.     and F.fk_paciente=P.pk_paciente     -- REUNIENDO FACT CON PACIENTE
  11.     and F.fk_tipo_ingreso=G.pk_tipo_ingreso -- REUNIENDO FACT CON TIPO INGRES
  12.     and F.fk_tiempo=T.pk_tiempo         -- REUNIENDO FACT CON TIEMPO
  13. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement