You are on page 1of 1

select

cod_deu,agencia,cod_luna,cod_sistema,tramo,telef_ges,telefono,convergencia,nom_deu,
mon_atr,
fec_sin,tip_rb,control1,control2,TMO,tipo_ges,nombre,codigo2,comentario,con_cam,sco
re,tip_con,usuario,
cod_piloto,ind34,ind35,ind36
FROM
(
select a.cod_deu,'CLASA'::character(5)
agencia,a.cod_luna,b.cod_sistema,e.descrip_clave tramo,b.telef_ges,
f.telefono,d.nombre convergencia,a.nom_deu,a.mon_atr,b.fec_sin,
b.tip_rb,b.control1,b.control2,
(cast(substring(b.control2,0,3) ||':'||substring(b.control2,4,2) ||':'||
substring(b.control2,7,2) as time) -
cast(substring(b.control1,0,3) ||':'||substring(b.control1,4,2) ||':'||
substring(b.control1,7,2) as time)) as TMO
, b.corta tipo_ges,c.nombre,c.codigo2,b.comentario,b.con_cam,h.nombre
score,b.tip_con,c.usuario,
g.cod_piloto, g.ind_varibles_ext_tdp_1 ind34, g.ind_varibles_ext_tdp_2
ind35,g.ind_varibles_ext_tdp_3 ind36,
ROW_NUMBER () OVER (PARTITION BY b.cod_deu,b.usuario,b.control1 order by TMO desc)
Fila
from g110 a
inner join g220 b on a.cod_deu=b.cod_deu
inner join sys_usr c on b.usuario=c.usuario
left join core_convergencia d on a.cod_uga::integer = d.cod_convergencia
left join core_claves e on a.clave=e.clave
left join master_servicio f on a.cod_deu=f.cod_deu and
b.cod_cuenta=f.cod_cuenta::integer and b.cod_sistema=f.cod_sistema
left join g110_cta g on b.cod_deu=g.cod_deu
left join core_score h on g.cod_score=h.cod_score
where b.cod_ban='25' and b.tip_con not in ('GS','GN','IV','MT','ML') and b.fec_sin
= '2018-03-22'
and b.usuario not in ('CV','PT','PJ')
) T1
where T1.fila = '1'

You might also like