I've a table of users and one of the columns is User_ID (naming policy = first letter of first name and rest is the last name. If a name is exists, then increment by 1).
For example: John Doe -> user_id=jdoe
If jdoe already exists then user_id = jdoe1
The input for the query is a basic user_id (e.g. jdoe) I would like to scan the table and for the output of the query to be: a new distinct value of user_id.
If the table has the following values:
jdoe
jdoe1
jdoe2
jdoe3
The output should be jdoe4.
Any help will be appreciated.
Thanks
P.S
Changes to the table are not allowed.
The value from the query is being used with another system (active directory)