create table tmp_table(
item varchar2(6),
period number(1),
slot varchar2(1));
insert into tmp_table values('abc123',1,'A');
insert into tmp_table values('abc123',2,'A');
insert into tmp_table values('abc123',3,'A');
insert into tmp_table values('abc123',4,'B');
insert into tmp_table values('abc123',5,'B');
insert into tmp_table values('abc123',6,'C');
insert into tmp_table values('abc123',7,'A');
insert into tmp_table values('abc123',8,'A');
insert into tmp_table values('abc123',9,'C');
insert into tmp_table values('def456',1,'D');
insert into tmp_table values('def456',2,'D');
insert into tmp_table values('def456',3,'E');
insert into tmp_table values('def456',4,'E');
insert into tmp_table values('def456',5,'D');
insert into tmp_table values('def456',6,'D');
insert into tmp_table values('def456',7,'E');
insert into tmp_table values('def456',8,'E');
insert into tmp_table values('def456',9,'D');
commit;
select item,period,slot,
min(period) over(partition by item,slot,SubRank) as minPeriod,
Row_Number() over(partition by item,slot,SubRank order by period) as Rank
from (select item,period,slot,
period-Row_Number() over(partition by slot order by period) as SubRank
from tmp_table)
order by item,period;