oracle数据库排序后获取第一条数据

场景:

想要获取下列sql的数据的第一条

select NEXT_FOLLOWUP_DATE
  from PH_CHILD_HEALTH_EXAM
 where person_info_id = '3afc119ab460497d85f59b1e135ea6b1'
 order by followup_Visit_Date desc

oracle数据库排序后获取第一条数据_第1张图片

实现:

select NEXT_FOLLOWUP_DATE
  from (select NEXT_FOLLOWUP_DATE
          from PH_CHILD_HEALTH_EXAM
         where person_info_id = '3afc119ab460497d85f59b1e135ea6b1'
           and is_Cancel = 0
         order by followup_Visit_Date desc)
 where rownum = 1;

oracle数据库排序后获取第一条数据_第2张图片

你可能感兴趣的:(数据库,oracle)