Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 2 - For each admission, show the type, date, procedence service, duration, and the average duration of the admissions of its same procedence.
- SELECT S.servicio_procedencia, G.tipo, P.sexo, T.fecha, F.duracion
- , avg(duracion) over (partition by servicio_procedencia)
- from dw_ingresos.dw_fact_ingreso F,
- dw_ingresos.dw_dim_proc S,
- dw_ingresos.dw_dim_tipoingreso G,
- dw_ingresos.dw_dim_paciente P,
- dw_ingresos.dw_dim_time T
- where F.fk_procedencia=S.pk_procedencia -- REUNIENDO FACT CON PROCEDENCIA
- and F.fk_paciente=P.pk_paciente -- REUNIENDO FACT CON PACIENTE
- and F.fk_tipo_ingreso=G.pk_tipo_ingreso -- REUNIENDO FACT CON TIPO INGRES
- and F.fk_tiempo=T.pk_tiempo -- REUNIENDO FACT CON TIEMPO
- ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement