update records to have occurance number - Mailing list pgsql-general

From Mark Lybarger
Subject update records to have occurance number
Date
Msg-id CAKM-gmJXa90rKwiQ7Z4VXyBzaHAONzT7s1Z+aAvsHiFJ_budLw@mail.gmail.com
Whole thread Raw
Responses Re: update records to have occurance number  (Alban Hertroys <haramrae@gmail.com>)
Re: update records to have occurance number  (Cachique <cachique@gmail.com>)
List 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 by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: configure PostgreSQL with PERL: Perl version 5.8 or later is required, but this is .
Next
From: "t.dalpozzo@gmail.com"
Date:
Subject: streaming replication and WAL