row_number() over(order by col2 desc)用法

来源:互联网 发布:数据库中主键和外键 编辑:程序博客网 时间:2024/05/16 11:33

select *
from (select t.*,row_number() over(partition by t.at_ab_id_n order by t.AT_SETTLE_DATE_D desc ) cn
        from mypay_account_settle t where 
        t.at_ab_id_n=201001151300000002  and
        to_char(t.at_tx_date_d,'yyyymmdd') <= &apl_date  and
        t.at_settle_type_c = '0001' )d
where cn = 1 order by d.at_tx_date_d desc;