select Code,Seq,SubSeq,
max(SubSeq) Keep (Dense_Rank Last order by Seq) over(partition by Code) as maxSubSeq
from (select 'AAAA' as Code,100 as Seq,1 as SubSeq from dual
union select 'AAAA',150,1 from dual
union select 'AAAA',200,2 from dual
union select 'AAAA',200,3 from dual
union select 'AAAA',250,1 from dual
union select 'AAAA',250,2 from dual
union select 'BBBB',300,1 from dual
union select 'BBBB',300,2 from dual
union select 'BBBB',300,3 from dual
union select 'BBBB',300,4 from dual
union select 'BBBB',300,5 from dual
union select 'BBBB',400,1 from dual
union select 'CCCC',600,1 from dual
union select 'CCCC',650,1 from dual
union select 'CCCC',750,1 from dual
union select 'CCCC',750,2 from dual
union select 'CCCC',750,3 from dual
union select 'CCCC',750,4 from dual
union select 'CCCC',750,5 from dual);