Interpolating Values - Mailing list pgsql-novice

From James David Smith
Subject Interpolating Values
Date
Msg-id CAMu32ADFw7v6rg+eDiMZyxQitGUazJ8nca_1kUsnR7vV_7g2FQ@mail.gmail.com
Whole thread Raw
List pgsql-novice
Hi everyone,

Some ideas about how to go about something would be appreciated
please. I have data that looks like this:

person_id      |               date_time                          |
  person_black_carbon
-----------------------------------------------------------------------------------------------------
       1             |        2012-07-12 10:48:00               |
             34
       1             |        2012-07-12 10:49:00               |
             567
       1             |        2012-07-12 10:50:00               |
             0
       1             |        2012-07-12 10:51:00               |
             98

       2             |        2012-07-12 10:48:00               |
             34
       2             |        2012-07-12 10:49:00               |
             0
       2             |        2012-07-12 10:50:00               |
             32
       2             |        2012-07-12 10:51:00               |
             98

       3             |        2012-07-12 10:48:00               |
             0
       3             |        2012-07-12 10:49:00               |
             567
       3             |        2012-07-12 10:50:00               |
             0
       3             |        2012-07-12 10:51:00               |
             98

You will see that for each person I have black carbon readings for
each minute. However what I actually need is a reading for each
second. What I have missed out of the table above is that inbetween
each of the minutes shown, there are an addition 59 rows which have
the correct time in date_time, but a blank person_black_carbon figure.
What I want to do is to fill in the person_black_carbon figure by
interpolating from the figure above/below it.

I hope that makes sense. Thanks for any help.

James


pgsql-novice by date:

Previous
From: "Oliveiros d'Azevedo Cristina"
Date:
Subject: Re: Need help (unterminated dollar-quoted string at or near "$$ LANGUAGE plpgsql IMMUTABLE; ")
Next
From: Sindile Bidla
Date:
Subject: Create a new table from records not joined in a left outer join