Interpolating Values

From: James David Smith <james(dot)david(dot)smith(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Interpolating Values
Date: 2012-09-12 15:39:07
Message-ID: CAMu32ADFw7v6rg+eDiMZyxQitGUazJ8nca_1kUsnR7vV_7g2FQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-novice by date

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