Hi
I have an Informix database containing measured temperature values for quite a few different locations. The measurements are taken every 15 min for all locations and then loaded with a timestamp into the same table. Table looks like this:
locId dtg temp aaa 2009-02-25 10:00 15 bbb 2009-02-25 10:00 20 ccc 2009-02-25 10:00 24 aaa 2009-02-25 09:45 13 ccc 2009-02-25 09:45 16 bbb 2009-02-25 09:45 18 ddd 2009-02-25 09:45 12 aaa 2009-02-25 09:30 11 ccc 2009-02-25 09:30 14 bbb 2009-02-25 09:30 15 ddd 2009-02-25 09:30 10
Now I would like a query that present me with the change in temperature between the two last measurements for all stations. And also, only the ones that has an updated measurement. For example in the table above, location ddd would not be included. So the result becomes:
locId change aaa 2 bbb 2 ccc 8
I have tried alot but I can´t find any good solution. In reality it is about 700 locations that is asked from a web page so I think the query needs to be fairly efficient.
Would really appreciate some help!
//Jesper