how to calculate differences of timestamps?

From: Andreas <maps(dot)on(at)gmx(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: how to calculate differences of timestamps?
Date: 2011-09-27 01:31:51
Message-ID: 4E812787.1080002@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

How could I calculate differences of timestamps in a log-table?

Table log ( user_id integer, login boolean, ts timestamp )

So login = true would be a login-event and login = false a logout.
Is there a way to find the matching login/logout to calculate the
difference?

Or is there a better table "design" to do this?

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tim Landscheidt 2011-09-27 02:42:16 Re: how to calculate differences of timestamps?
Previous Message Filip Rembiałkowski 2011-09-27 00:57:24 Re: handling duplicate row exception