Please help me write a query

From: Nikolas Everett <nik9000(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Please help me write a query
Date: 2010-05-27 14:04:37
Message-ID: AANLkTiluFJrwm29jg2TaJZFZnuUwVtris73kYpw_I_HO@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Say I have a table that stores state transitions over time like so:
id, transitionable_id, state1, state2, timestamp

I'm trying to write a query that coalesces changes in state2 away to produce
just a list of transitions of state1. I guess it would look something like

SELECT state1, FIRST(timestamp)
FROM table

but I have no idea how to aggregate just the repeated state1 rows.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ozz Nixon 2010-05-27 14:20:48 Re: Please help me write a query
Previous Message Thom Brown 2010-05-27 13:59:36 Re: 110,000,000 rows