Something like this?
SQL> with test (name, rank, revision, state) as
2 (select 'A', 0, '5b', 'ReadOnly' from dual union all
3 select 'A', 2, '4', 'Published' from dual union all
4 select 'A', 5, '1', 'Published' from dual union all
5 select 'B', 0, '2', 'Draft' from dual union all
6 select 'B', 1, '1', 'Published' from dual union all
7 select 'C', 0, '1', 'Published' from dual
8 )
9 select name, rank, revision, state
10 from (select t.*,
11 rank() over (partition by name order by revision desc, rank) rn
12 from test t
13 where state = 'Published'
14 )
15 where rn = 1;
N RANK RE STATE
- ---------- -- ---------
A 2 4 Published
B 1 1 Published
C 0 1 Published
SQL>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…