Update with a Repeating Sequence

From: Bill Thoen <bthoen(at)gisnet(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Update with a Repeating Sequence
Date: 2008-10-14 16:04:39
Message-ID: 48F4C317.4040305@gisnet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I've got a table with repeated records that I want to make unique by
adding a sequence code of 0,1,2,...,n for each set of repeated records.
Basically, I want to turn:
field_id | seq
----------+-----
1 | 0
2 | 0
3 | 0
3 | 0
3 | 0
4 | 0
4 | 0
5 | 0
6 | 0
into:
field_id | seq
----------+-----
1 | 0
2 | 0
3 | 0
3 | 1
3 | 2
4 | 0
4 | 1
5 | 0
6 | 0

What's the best way to that?

TIA,
- Bill Thoen

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Grzegorz Jaśkiewicz 2008-10-14 16:10:17 Re: Update with a Repeating Sequence
Previous Message Eric Haszlakiewicz 2008-10-14 15:49:47 Re: Re: BUG #4078: ERROR: operator does not exist: numeric = character varying