【问题标题】:Enable to count the rows of a subquery SQL Server 2008启用以计算子查询 SQL Server 2008 的行数
【发布时间】:2014-11-19 16:39:47
【问题描述】:

我收到以下错误消息:

  Msg 102, Level 15, State 1, Line 6
    Incorrect syntax near ')'.  

在尝试运行以下查询时:

select count(*) as count from
     (select distinct 
     POSITION,
     ACQUIESCEMENT,
     CODE_LIMITE_NATURELLE
       from avoisine where num_dossier=2 and indice='29'  ) 

我的查询有什么问题?

提前致谢。

【问题讨论】:

  • AS [count] /* reserved word */ FROM (select ...) AS x -- need alias

标签: sql-server sql-server-2008 count subquery


【解决方案1】:

你错过了alias name

select count(*) as [count] from
     (select distinct 
     POSITION,
     ACQUIESCEMENT,
     CODE_LIMITE_NATURELLE
       from avoisine where num_dossier=2 and indice='29'  ) A -- Missing

【讨论】:

    猜你喜欢
    • 2023-04-08
    • 1970-01-01
    • 2013-09-23
    • 1970-01-01
    • 2011-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多