विंडो फ़ंक्शन का उपयोग करें:
select role, name,
row_number() over (partition by role order by name) as rn
from the_table
order by name;
विंडो फ़ंक्शन का उपयोग करें:
select role, name,
row_number() over (partition by role order by name) as rn
from the_table
order by name;