update records to have occurance number
От | Mark Lybarger |
---|---|
Тема | update records to have occurance number |
Дата | |
Msg-id | CAKM-gmJXa90rKwiQ7Z4VXyBzaHAONzT7s1Z+aAvsHiFJ_budLw@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: update records to have occurance number
Re: update records to have occurance number |
Список | pgsql-general |
I want to update a table to have the value of the occurrence number. For instance, I have the below table. I want to update the number column to increment the count of last name occurrences, so that it looks like this:
first last 1
second last 2
third last 3
first other 1
next other 2
Here's my simple table:
create table person ( fname text, lname text, number integer);
insert into person (fname, lname) values ('first', 'last');
insert into person (fname, lname) values ('second', 'last');
insert into person (fname, lname) values ('third', 'last');
insert into person (fname, lname) values ('first', 'other');
insert into person (fname, lname) values ('next', 'other');
How would I issue an update statement to update the number column?
thanks!
В списке pgsql-general по дате отправления: