Re: Please help me write a query

Поиск
Список
Период
Сортировка
От Justin Graf
Тема Re: Please help me write a query
Дата
Msg-id 4BFE9AF8.7000206@magwerks.com
обсуждение исходный текст
Ответ на Please help me write a query  (Nikolas Everett <nik9000@gmail.com>)
Список pgsql-general
On 5/27/2010 9: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.

if i understand what your  after

Select distinct transitinable_id, state1,  min(timestamp) from table
group by  transitinable_id, state1















All legitimate Magwerks Corporation quotations are sent in a .PDF file attachment with a unique ID number generated by
ourproprietary quotation system. Quotations received via any other form of communication will not be honored. 

CONFIDENTIALITY NOTICE: This e-mail, including attachments, may contain legally privileged, confidential or other
informationproprietary to Magwerks Corporation and is intended solely for the use of the individual to whom it
addresses.If the reader of this e-mail is not the intended recipient or authorized agent, the reader is hereby notified
thatany unauthorized viewing, dissemination, distribution or copying of this e-mail is strictly prohibited. If you have
receivedthis e-mail in error, please notify the sender by replying to this message and destroy all occurrences of this
e-mailimmediately. 
Thank you.


В списке pgsql-general по дате отправления:

Предыдущее
От: erobles
Дата:
Сообщение: Re: hi, trying to compile postgres 8.3.11
Следующее
От: Tom Lane
Дата:
Сообщение: Re: hi, trying to compile postgres 8.3.11