pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jan Peters <petersjan@gmx.at>
To: pgsql-sql@postgresql.org
Subject: Number timestamped rows
Date: Wed, 02 Nov 2011 17:36:19 +0100
Message-ID: <20111102163619.135780@gmx.net> (raw)

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



view thread (3+ messages)  latest in thread

Message-ID: <20111102163619.135780@gmx.net>
Permalink:  ../20111102163619.135780@gmx.net/
Also on:    postgresql.org/message-id/20111102163619.135780@gmx.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: petersjan@gmx.at
  Subject: Re: Number timestamped rows
  In-Reply-To: <20111102163619.135780@gmx.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox