I have a table which contains two columns, one named "ID", and the other is "FLG". I need to add anther column "FLG1" that based on column "FLG".
The process logic is that if one record is "Y" in this table, then the next 2 records should be both "N" in "FLG1", if it is "N", then just keep it in "FLG1".
For example:
For record which ID=2 and FLG=Y,then FLG1 of this record should be "Y", but for the next 2 records(ID=3,4), FLG1 should be "N", though their FLG is "Y".
The expected result is as below:

I have tried many ways for days but failed and I don't want a stored procedure, I just want SQL query scripts for the implementation.
Here is the scripts for the data:
select 1 as ID, 'N' as FLG from dual union all
select 2 as ID, 'Y' as FLG from dual union all
select 3 as ID, 'Y' as FLG from dual union all
select 4 as ID, 'Y' as FLG from dual union all
select 5 as ID, 'Y' as FLG from dual union all
select 6 as ID, 'Y' as FLG from dual union all
select 7 as ID, 'Y' as FLG from dual union all
select 8 as ID, 'Y' as FLG from dual union all
select 9 as ID, 'N' as FLG from dual union all
select 10 as ID, 'Y' as FLG from dual union all
select 11 as ID, 'N' as FLG from dual union all
select 12 as ID, 'Y' as FLG from dual union all
select 13 as ID, 'N' as FLG from dual union all
select 14 as ID, 'N' as FLG from dual union all
select 15 as ID, 'N' as FLG from dual union all
select 16 as ID, 'Y' as FLG from dual union all
select 17 as ID, 'N' as FLG from dual union all
select 18 as ID, 'N' as FLG from dual union all
select 19 as ID, 'N' as FLG from dual union all
select 20 as ID, 'N' as FLG from dual union all
select 21 as ID, 'N' as FLG from dual union all
select 22 as ID, 'Y' as FLG from dual union all
select 23 as ID, 'Y' as FLG from dual