select B.length_total1, A.length_total2,A.time from
(select sum(Length) as length_total2,time
from T_union20100908 where Class=1 and Speed between 20 and 35 group by time) A,
(select sum(Length) as length_total1,time
from T_union20100908 where Class=1 and Speed<=20 group by time) B
where A.time=B.time
(select sum(Length) as length_total2,time
from T_union20100908 where Class=1 and Speed between 20 and 35 group by time) A,
(select sum(Length) as length_total1,time
from T_union20100908 where Class=1 and Speed<=20 group by time) B
where A.time=B.time
from
(select sum(Length) as length_total1,time
from T_union20100908 where Class=1 and Speed<=20 group by time)as a
join
(select sum(Length) as length_total2,time
from T_union20100908 where Class=1 and Speed between 20 and 35 group by time
)as b
on a.time=b.time
你要是5个表的话;你就JOIN 5次。。LZ你也教教我撒
select a.length_total1,b.length_total2,a.time
from
(select sum(Length) as length_total1,time
from T_union20100908 where Class=1 and Speed<=20 group by time)as a
join
(select sum(Length) as length_total2,time
from T_union20100908 where Class=1 and Speed between 20 and 35 group by time
)as b
on a.time=b.time