[Igor Tandetnik]

> Steinar Midtskogen <stei...@latinitas.org> wrote:
>> 
>> Thanks, I didn't think in that simple terms. :) I think about listing
>> all the values, so I got lost.

I lost a word there: "I didn't think about listing"...

>> 
>> But what if the tables share a timestamp, then I would get, say:
>> 
>> 1328873300|1|2| | | |
>> 1328873300| | |3| | |
>> 1328873300| | | |4|5|6
>> 
>> How can that get collapsed into:
>> 
>> 1328873300|1|2|3|4|5|6
>
> Try something like this:
>
> select timestamp, value1, ..., value6 from
> (select timestamp from tab1
>  union
>  select timestamp from tab2
>  union
>  select timestamp from tab3)
> left join tab1 using (timespamp)
> left join tab2 using (timespamp)
> left join tab3 using (timespamp);

Wonderful!  It also eliminates the need to list all the nulls and
values, and as a bonus it gets ordered by timestamp whereas the
previous solution required an "ORDER BY timestamp" which made
everything slower than this solution (for some reason).

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

Reply via email to