select * from (select * from xx where a=1) tem where tt=2

解决方案 »

  1.   

    eg:
    1: Select a,b,c,d from table1 where ...
    2:
       Select a,sum(b) from 
         (Select a,b,c,d from table1 where ...) abcd --别名,可以任意指定
       group by a
      

  2.   

    3:再加一层
      Select * from (
    Select a,sum(b) from 
         (Select a,b,c,d from table1 where ...) abcd --别名,可以任意指定
       group by a
    ) ab
    where a > 100
      

  3.   


    用临时表可以实现:select * into #aa from xx where a=1select * from #aa where tt=2drop table #aa
      

  4.   

    select * from (select * from xx where a=1) 别名必须写,但你可以随便写一个 where tt=2
      

  5.   

    to  yujohny(踏网无痕)
    我也是这样想的,但是临时表是有生存周期的。
    我现在的问题是当我执行完一个sql后,我可以把结果放到临时表中,但我不知道当我执行下一个sql的时候这张临时表是否还存在,还有就是我能不能把查询结果存入这张临时表中
      

  6.   

    那你可以做一个全局临时表阿, 完了再drop不就可以了吗