"select * from ( select (select code from kklw.checkpoint_code where code=kkbh and type='2') code,"+
"(select display from kklw.checkpoint_code where code=t1.kkbh ) diaplay, "+
"sum(t1.jsl)+sum(t1.csl) ,sum(t1.jsl) ,sum(t1.csl) ,sum(t1.sbsl),sum(t1.wsbsl) "+
" from kklw.vehicle_flow_statis_hour t1 where t1.sj>='"+weekstart0+"' and t1.sj<='"+weekend0+"'"+
"group by t1.kkbh) t where t.code is not null";
t和t1是什么,为什么要用他们

解决方案 »

  1.   

    t和t1 都是表名代替 ,你完全可以用a ,b   来代替,
    也可以不用,如果你不闲麻烦写表的名字
      

  2.   

    能详细将将每条语句的含义吗?
    为什么括号外面有code,display
      

  3.   

    string str="select   *   from   (   select   (select   code   from   kklw.checkpoint_code   where   code=kkbh   and   type= "2 ")   code,"+ 
    "(select   display   from   kklw.checkpoint_code   where   code=t1.kkbh   )   diaplay,   "+ 
    "sum(t1.jsl)+sum(t1.csl)   ,sum(t1.jsl)   ,sum(t1.csl)   ,sum(t1.sbsl),sum(t1.wsbsl)   "+ 
    "   from   kklw.vehicle_flow_statis_hour   t1   where   t1.sj >= ""+weekstart0+" "   and   t1.sj <= ""+weekend0+" ""+ 
    "group   by   t1.kkbh)   t   where   t.code   is   not   null"; 
      

  4.   

    t,t1是表的别名;
    code,diaplay是对应所作选取列的别名,
    为了书写和阅读直观,明了!