Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 419CB6321CA for ; Mon, 2 Aug 2010 23:58:32 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 81552-09 for ; Tue, 3 Aug 2010 02:58:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.gmx.net (mailout-de.gmx.net [213.165.64.22]) by mail.postgresql.org (Postfix) with SMTP id A116762E9C6 for ; Mon, 2 Aug 2010 23:58:24 -0300 (ADT) Received: (qmail invoked by alias); 03 Aug 2010 02:58:21 -0000 Received: from p5481C395.dip.t-dialin.net (EHLO [192.168.1.203]) [84.129.195.149] by mail.gmx.net (mp014) with SMTP; 03 Aug 2010 04:58:21 +0200 X-Authenticated: #14269776 X-Provags-ID: V01U2FsdGVkX19B5G9Z0E1BvHQ1PAENlGPlSe30BkGHfTbnaZNxp6 nCRwOJ+WXpvB2a Message-ID: <4C5785D7.8040907@gmx.net> Date: Tue, 03 Aug 2010 04:58:31 +0200 From: Andreas User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.7) Gecko/20100713 Thunderbird/3.1.1 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Help Need some hindsight Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.79 tagged_above=-5 required=5 tests=BAYES_50=0.8, RCVD_IN_DNSWL_NONE=-0.0001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201008/9 X-Sequence-Number: 34449 Hi, I need to display log events (again). The log is simply like this log ( log_id serial primary key, create_ts timestamp default localtimestamp, object_id, state_id, ....... ) It records the state of objects and when and what happend to to change this state. I'd like to get a list that shows the current state at any point of time and the state of the last event before regarding the current object_id. The tricky bit is that both states should appear in the same row for every row. Help? :)