Number timestamped rows

From: "Jan Peters" <petersjan(at)gmx(dot)at>
To: pgsql-sql(at)postgresql(dot)org
Subject: Number timestamped rows
Date: 2011-11-02 16:36:19
Message-ID: 20111102163619.135780@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Dear all,
maybe a stupid question, but: I have a table that is ordered like this:

user_id|timestamp|event
1 |0:1 |event_a
1 |0:2 |event_b
2 |0:1 |event_b
2 |0:3 |event_c
2 |0:4 |event_b
3 |0:1 |event_a

and I would like to number them according to their timestamps like this:

user_id|timestamp|event |order
1 |0:1 |event_a |1
1 |0:2 |event_b |2
2 |0:1 |event_b |1
2 |0:3 |event_c |2
2 |0:4 |event_b |3
3 |0:1 |event_a |1

How would I do this with an UPDATE statement (e.g.) in pgsql?

Thanks in advance for any hint
Jan

--
NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie!
Jetzt informieren: http://www.gmx.net/de/go/freephone

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Andreas Kretschmer 2011-11-02 16:51:23 Re: Number timestamped rows
Previous Message Ivan Sergio Borgonovo 2011-11-02 10:16:42 \COPY in psql using \e