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

解决方案 »

  1.   

    那如果是三个表呢,我才发觉我这里是五个表呢要五个select!!!!
      

  2.   

    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
      

  3.   

    那个大大告诉我咋个插入 SQL code 啊。。像lz上面那样的语句。我这样整的代码好难看。。
    你要是5个表的话;你就JOIN  5次。。LZ你也教教我撒
      

  4.   


    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