Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用最新记录消除oracle中的价值_Oracle - Fatal编程技术网

如何使用最新记录消除oracle中的价值

如何使用最新记录消除oracle中的价值,oracle,Oracle,输出 这是我试图获取最新记录的代码,但它对我不起作用。我会附上一张图片以便更好地理解。你能找出那个问题吗 您正在按ID进行分区,以便获得结果中的所有行。 我想应该是这样 select * from (select id,NPCI_REFMSGID,TO_CHAR (created_date, 'dd.mm.rrrr hh24:mi:ss.ff3')AS created_Date, rank() over (partition by ID order

输出 这是我试图获取最新记录的代码,但它对我不起作用。我会附上一张图片以便更好地理解。你能找出那个问题吗


您正在按ID进行分区,以便获得结果中的所有行。 我想应该是这样

    select *
    from (select
       id,NPCI_REFMSGID,TO_CHAR (created_date, 'dd.mm.rrrr hh24:mi:ss.ff3')AS created_Date, 
      rank() over (partition by ID order by TO_CHAR (created_date, 'dd.mm.rrrr hh24:mi:ss.ff3') desc) r
      from emnd_tblemandate_mst
      --where end_enrollment_date is null
    )
    where r = 1 AND NPCI_REFMSGID='1ea345bc63644b53a88076040ef979e3'
然后,您只会获得特定NPCI_REFMSGID的最新记录

    select *
    from (select
       id,NPCI_REFMSGID,TO_CHAR (created_date, 'dd.mm.rrrr hh24:mi:ss.ff3')AS created_Date, 
      rank() over (partition by ID order by TO_CHAR (created_date, 'dd.mm.rrrr hh24:mi:ss.ff3') desc) r
      from emnd_tblemandate_mst
      --where end_enrollment_date is null
    )
    where r = 1 AND NPCI_REFMSGID='1ea345bc63644b53a88076040ef979e3'
select *
from (select id 
           , NPCI_REFMSGID
           , TO_CHAR (created_date, 'dd.mm.rrrr hh24:mi:ss.ff3')AS created_Date
           , rank() over (partition by NPCI_REFMSGID order by created_date desc) r
      from   emnd_tblemandate_mst
)
where r = 1 
AND   NPCI_REFMSGID = '1ea345bc63644b53a88076040ef979e3'