I've rethought the interpolation strategy.  It's not important to be
able to look up any timestamp, just the timestamps that actually have
values in at least one table.  Let's say I have N tables, each with a
timestamp as primary key.  For instance:

tab1:
timestamp|value1|value2
1328873000|1|2  
1328873100|3|4  
1328873200|5|6  

tab2:
timestamp|value3
1328873050|7
1328873150|8 
1328873250|9

tab3:
timestamp|value4|value5|value6
1328873075|10|13|16
1328873175|11|14|17
1328873275|12|15|18

First, I'd like to merge all tables to create one single table with
every timestamp and every value.  That is, it will have the timestamps
that I get by:

 SELECT timestamp FROM tab1 UNION
 SELECT timestamp FROM tab2 UNION
 SELECT timestamp FROM tab3;

So the resulting table should be:

timestamp|value1|value2|value3|value4|value5|value6
1328873000|1|2| |  |  |
1328873050| | |7|  |  |
1328873075| | | |10|13|16
1328873100|3|4| |  |  |
1328873150| | |8|  |  |
1328873175| | | |11|14|17
1328873200|5|6| |  |  |
1328873250| | |9|  |  |
1328873275| | | |12|15|18

The resulting table will have a lot of NULLs.  Next, I'd like to fill
out all NULLs by using linear interpolation.

But, first things first, how can I merge my tables to get the combined
table with NULLs?  I've been playing with JOIN and UNION, but I'm
afraid my SQL experience is very limited, so I got stuck at this one.

In reality I have 7 tables to be merged with a lot of columns (perhaps
100 in all) and up to a million rows, so if an SQL statement to do
this sounds unrealistic, that would be a good answer as well.

Thanks,
-- 
Steinar Midtskogen
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to