如何使用最新记录消除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'