Here is the test code Code
with Test as
( select 'A' as Cat, 'AB' as Typ from dual
union
select 'A' as Cat, 'AC' as Typ from dual
union
select 'A' as Cat, 'AE' as Typ from dual
union
select 'B' as Cat, 'AC' as Typ from dual
union
select 'C' as Cat, 'AB' as Typ from dual
UNION
SELECT 'C' as Cat, 'AE' AS Typ from dual)
select (case when Typ = 'AB' then 1 else 0 end) as N,
(case when Typ = 'AB' then row_number() over (partition by Cat order by Cat asc) end) as r,
Cat, Typ from Test;
Here is the Output I get,
Expected Output:
I want the entire column to get populated when there is a match with value ‘AB’
Either 1 of the below outputs is desired.