Flatten table using timestamp and source

From: Elrich Marx <elrich(dot)marx(at)rorotika(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Flatten table using timestamp and source
Date: 2012-05-24 09:01:56
Message-ID: 73a6b75b83b37093e5e2751fc59c4323@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Good day.

I am quite new to Postgres, so please bear with me.

I have a table with data in the following format:

Table name : Time_Source_Table

Source , Stime

1, "2012-05-24 13:00:00"

1, "2012-05-24 13:01:00"

1, "2012-05-24 13:02:00"

2, "2012-05-24 13:03:00"

2, "2012-05-24 13:04:00"

1, "2012-05-24 13:05:00"

1, "2012-05-24 13:06:00"

I’m trying to get to a result that flattens the results based on source,
to look like this:

Source, Stime, Etime

1, "2012-05-24 13:00:00","2012-05-24 13:02:00"

2, "2012-05-24 13:03:00","2012-05-24 13:04:00"

1, "2012-05-24 13:05:00","2012-05-24 13:06:00"

Where Etime is the last Stime for the same source.

Any suggestions would be much appreciated.

Regards

El

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Raj Mathur ( राज =?utf-8?b?IOCkruCkvuCkpeClgeCksA==?=) 2012-05-24 11:59:20 Re: Flatten table using timestamp and source
Previous Message Oliveiros d'Azevedo Cristina 2012-05-24 08:27:56 Re: left outer join only select newest record