Numerate duplicate of every value I need to add a column to my table with the count of every occurrence of. So if the value is unique the column value should be 1, but if there is multiple copy i need a differente value for every row (1,2...)
The database is postgres
for example




id
value
count




1
a
1


2
a
2


3
b
1


4
b
2


5
b
3


6
c
1




database example https://dbfiddle.uk/?rdbms=postgres_10&amp;fiddle=0e7132f3f094bd93b390ccae2e811696
This can done using window functions
select id, value, count(*) over (partition by value order by id) 
from the_table
order by id, value;