只是一个简单的嵌套查询,为什么在ACCESS下数据库行,在SQL SERVER下不行?为什么,谁能给点提示!
select * from Table1 where ATime>=:t1 and BTime<=:t2
这个查询是成功的
接下的来就不对了
select count(*),sum(MYMONEY) from(select * from Table1 where ATime>=:t1 and BTime<=:t2
) where TypeOP=:t100
报错!Incorrect syntax near the keyword where
但是用ACCESS中就可以的,为什么,不知道那位兄弟是否也有同样的经历!

解决方案 »

  1.   

    select count(*),sum(MYMONEY) from(select * from Table1 where ATime>=:t1 and BTime<=:t2 and TypeOP=:t100
    )TypeOP=:t100把这个放到里面
      

  2.   

    select count(*),sum(MYMONEY) from(select * from Table1 where ATime>=:t1 and BTime<=:t2
    ) a 
    where TypeOP=:t100加个a应该就可以了
      

  3.   

    同意 heixiu1980(heixiu1980) :
    select count(*),sum(MYMONEY) from(select * from Table1 where ATime>=:t1 and BTime<=:t2) a 
    where TypeOP=:t100
      

  4.   

    select count(*),sum(MYMONEY) from(select * from Table1 where ATime>=:t1 and BTime<=:t2
    ) as t1 where TypeOP=:t100