pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Elrich Marx <elrich.marx@rorotika.com>
To: pgsql-sql@postgresql.org
Subject: Flatten table using timestamp and source
Date: Thu, 24 May 2012 11:01:56 +0200
Message-ID: <73a6b75b83b37093e5e2751fc59c4323@mail.gmail.com> (raw)

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

view thread (6+ messages)  latest in thread

Message-ID: <73a6b75b83b37093e5e2751fc59c4323@mail.gmail.com>
Permalink:  ../73a6b75b83b37093e5e2751fc59c4323@mail.gmail.com/
Also on:    postgresql.org/message-id/73a6b75b83b37093e5e2751fc59c4323@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: elrich.marx@rorotika.com
  Subject: Re: Flatten table using timestamp and source
  In-Reply-To: <73a6b75b83b37093e5e2751fc59c4323@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox