Search Postgresql Archives

Re: Please help me write a query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux