 <pre><code>with x as (select *, row_number() over(order by SYS_CREAT_TS desc) as rn from DATA_STUS) SELECT RVSN FROM x WHERE rn =1 and DATA_STUS_CD = 2 </code></pre> <p>If the data needs partitioning by a column, add it to the <code>over</code> clause so you get the desired results.</p>