select count(*) from ( select tmh from TDATA group by tmh )我想统计分组之后的记录数量,查网上的资料,这样写应该可以的,但是在SQL2000下面怎么试都不行,老是出现下面错误:服务器: 消息 170,级别 15,状态 1,行 2
第 2 行: ')' 附近有语法错误。请教各位高手.

解决方案 »

  1.   

    select count(*) from ( select tmh from TDATA group by tmh )  m
      

  2.   

    select count(*) from ( select tmh from TDATA group by tmh ) tb
      

  3.   

    SQL 必须要加个别名,微软规定的。
      

  4.   

    select count(distinct tmh) from TDATA  
      

  5.   


    Select Count(1) from ( Select tmh From TDATA Group By tmh ) Table
    正解,顶 
      

  6.   

    原来是FIREBIRD数据库来的,它就不用加上别名,搞晕我了,查了一个多小时了...
      

  7.   

    这个叫派生表,是一种从查询表达式派生出虚拟结果表的表达式,使用派生表的形式如下:
      from (derived_table_query expression) as derived_table_alias
      

  8.   

    来晚了,加个别名就可以了。
    select count(*) from ( select tmh from TDATA group by tmh ) aa
      

  9.   

    select count(*) from ( select tmh from TDATA group by tmh ) TT
    加个表别名
      

  10.   

    select count(*) from ( select tmh from TDATA group by tmh ) table1
      

  11.   


    select count(*) from ( select tmh from TDATA group by tmh ) as a这种from 一个子句的一定要加个别名
    有的情况比如链接
    select * into aa from (select * from a where id>30) as a 
    这样的也是一样一定要加别名,有的时候比如用子句来进行join 关联,也是要加别名的。
      

  12.   

    --加个别名
    select count(*) from ( select tmh from TDATA group by tmh ) A
      

  13.   


    select count(*) from ( select tmh from TDATA group by tmh ) name
    -- 加个名字,告诉前面的人:我这是一个表啊
      

  14.   

    晕,又忘了 UBB里是不能改变颜色的。
      

  15.   

    早点来就好了,
    select count(a.*) from ( select tmh from TDATA group by tmh ) as a
    只有顶了