Skip to content
Advertisement

Display duplicate column with increasing count in separate coloumn in sql

I want to increase count in count column one by one if the same Id is found in records.

Don’t consider about auto increment of Id.

MySQL version 8.0 and you can order by name column.

I tried but not getting any solution.

My table Employee looks like this

I want to run sql query which will give output like this, if Id is same increase count

Advertisement

Answer

The ROW_NUMBER() function can generate your current count column, more or less:

Note that ROW_NUMBER requires MySQL 8+.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement