Steinar Midtskogen <stei...@latinitas.org> wrote:
> 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
> 
> 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
> 
> But, first things first, how can I merge my tables to get the combined
> table with NULLs?

select value1, value2, null, null, null, null from tab1
union all
select null, null, value3, null, null, null from tab2
union all
select null, null, null, value4, value5, value6 from tab3;

-- 
Igor Tandetnik

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

Reply via email to