Re: Please help me write a query

From: Ozz Nixon <ozznixon(at)gmail(dot)com>
To: Nikolas Everett <nik9000(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Please help me write a query
Date: 2010-05-27 14:20:48
Message-ID: EB0C4A7F-25B8-4E15-80D8-A1DAC68DDCB3@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Lost me a bit, do you mean DISTINCT?

select distinct state1, first(timestamp) from table????

On May 27, 2010, at 10:04 AM, Nikolas Everett wrote:

> 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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message erobles 2010-05-27 14:42:46 hi, trying to compile postgres 8.3.11
Previous Message Nikolas Everett 2010-05-27 14:04:37 Please help me write a query