oracle根据查询条件、时间降序排序查询出最新的一条数据并更新

update TBL_SQZL
set HYJG = 1
where ID = (
select ID
from (
select ID
from TBL_SQZL
where JYTGM is not null
and XM = '郭玉珍'
and ZJHM = '310101194307254025'
and ZJLX = '01'
order by CRT_TIMESTAMP desc)
where ROWNUM = 1
);

select准确查出一条数据,整体执行的时候就一直转圈圈……表数据有两万四千多条,是需要优化还是怎么滴?

又是靠自己。。
通过Oracle的开窗函数over(partition by):

update TBL_SQZL
set HYJG = '1'
where ID = (
  select t2.ID
  from (select t.*,
               row_number() over (
                 PARTITION BY t.ZJHM
                 ORDER BY
                   t.CRT_TIMESTAMP DESC
                 ) as row_flg
        from TBL_SQZL t) t2
  where t2.JYTGM is not null
    and t2.XM = '郭玉珍'
    and t2.ZJHM = '310101194307254025'
    and t2.ZJLX = '01'
    and t2.row_flg = '1');

你子查询里都没有加top 1

update TBL_SQZL
set HYJG = 1
where JYTGM is not null
and XM = '郭玉珍'
and ZJHM = '310101194307254025'
and ZJLX = '01'
and CRT_TIMESTAMP >=(select max(b.CRT_TIMESTAMP) from TBL_SQZL b)