• Something like this?

    SELECT x.id

    , DENSE_RANK() OVER (ORDER BY x.id) as DenseRnk

    FROM

    (SELECT 'A123' AS ID

    UNION ALL

    SELECT 'A124'

    UNION ALL

    SELECT 'A124'

    UNION ALL

    SELECT 'A123'

    UNION ALL

    SELECT 'A127') x

    And then do like Phil said and join back to the original table to show where to put each item?