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  (Alban Hertroys <haramrae@gmail.com>)
Re: update records to have occurance number  (Cachique <cachique@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: configure PostgreSQL with PERL: Perl version 5.8 or later is required, but this is .
Следующее
От: "t.dalpozzo@gmail.com"
Дата:
Сообщение: streaming replication and WAL