I need to fetch array index when doing unnest. I tried row_number() Over() but this is calculating row number, not the array index. I also tried WITH ORDINALITY but it worked only with from clause.
select id, unnest(fname), status
from testunnest;
Rows in Table testunnest
112w,{john,sam},yes
2wew,{josh,Nick,Jeny},no
The above query is returning result as
112w john yes
112w sam yes
2wew josh No
2wew Nick No
2wew Jeny No
Expected is
112w john yes 1
112w sam yes 2
2wew josh No 1
2wew Nick No 2
2wew Jeny No 3