子查询问题,SQL Server 2008

woo*_*gie 1 sql sql-server subquery sql-server-2008

只是在SQL Server中使用子查询(我知道这个问题不必用子查询完成,但我想知道我的语法问题在哪里)

select count(*) from 
( select id, totalcharges from tblVisits where (totalcharges <10000))
Run Code Online (Sandbox Code Playgroud)

Bri*_*dge 6

我想你需要命名你的子查询 - 例如在这里将它别名为"t":

select count(*) from 
( select id, totalcharges from tblVisits where (totalcharges <10000)) t
Run Code Online (Sandbox Code Playgroud)

  • 确切地说,它需要参考它 (2认同)