I need to know the last record of an oracle table

0

please your support I need to know the last record in the table carga_diaria_sp taking as input eje_ejecucion?

select 

        a.telefono,
        b.origen as "LEGADO",
         (Select  CASE WHEN CNOMBRE_ARCH = 'NULL' THEN CDESCRIPCION ELSE CNOMBRE_ARCH END || ' (' || b.ope_donante  ||')'  From PT_MATRIZ_OPERADOR Where  NID_OPERADOR= b.ope_donante) OPE_DONANTE,
         (Select  CASE WHEN CNOMBRE_ARCH = 'NULL' THEN CDESCRIPCION ELSE CNOMBRE_ARCH END || ' (' || b.ope_receptor ||')'  From PT_MATRIZ_OPERADOR Where  NID_OPERADOR= b.ope_receptor) OPE_RECEPTOR,
        b.fecha_ejecucion PROGRAMACION,
        b.motivo_rechazo as "CODIGO RECHAZO",
        a.telefono as "TELEFONO"  

from 
        p_portabilidad a
        left join carga_diaria_sp b
        on a.telefono=b.telefono
where  b.ope_donante IN ('22','32')
and     b.FECHA_CREACION>=TO_DATE('20170101','yyyymmdd')
and     b.FECHA_CREACION<=TO_DATE('20180916','yyyymmdd')
        order by a.telefono
    
asked by werner 19.09.2018 в 19:42
source

1 answer

0

The order by should include:

b.fecha_ejecucion desc

And if at the end you just want a record as a result, you should wrap your query in the following way:

select * from 
  (tu consulta) 
where rownum=1;
    
answered by 20.09.2018 в 00:22