To lze snadno provést pomocí funkce okna:
select Name,
Value,
dense_rank() over (order by name) - 1 as idx
from table
order by Name;
To lze snadno provést pomocí funkce okna:
select Name,
Value,
dense_rank() over (order by name) - 1 as idx
from table
order by Name;