SELECT COUNT(*) FORM (SELECT a,b FROM t_TABLE)

解决方案 »

  1.   

    你不就是要取行数吗??
    SELECT COUNT(*) FORM (SELECT a,b FROM t_TABLE)
      

  2.   

    补充一下我的意图: 在t_Table表里面有两个列 a,b ,但是a,b是可以重复的 比如有两个(1,1)这样的行,我想取出不重复的行的行数. 怎么搞呢? 我用
    SELECT COUNT(*)FORM(SELECT a,b FROM t_TABLE GROUP BY a,b )
    通不过,是错误的
    错误消息------>
    服务器: 消息 170,级别 15,状态 1,行 7
    第 7 行: ')' 附近有语法错误。请高手赐教
      

  3.   

    里面不要分组啊!
    你干么要分组?SELECT COUNT(*)FORM(SELECT distinct a,b FROM t_TABLE )
      

  4.   

    create table test
    (
    a int,
    b int
    )insert into test values(1,1)
    insert into test values(1,1)
    insert into test values(1,1)
    insert into test values(61,1)
    insert into test values(21,1)select count(*)
    from 
    (
    select distinct a,b from test
    )还是有错,原封不动复制过来的,错误信息
    服务器: 消息 170,级别 15,状态 1,行 17
    第 17 行: ')' 附近有语法错误。
      

  5.   

    create table test
    (
    a int,
    b int
    )insert into test (a,b) values(1,1)
    insert into test (a,b) values(1,1)
    insert into test (a,b) values(1,1)
    insert into test (a,b) values(61,1)
    insert into test (a,b) values(21,1)select count(*)
    from (select distinct a,b from test) a----------- 
    3(所影响的行数为 1 行)
      

  6.   

    select count(1) from (select distinct a,b from table1) a
      

  7.   

    SELECT COUNT(*)FROM(SELECT a,b FROM t_TABLE GROUP BY a,b ) A --你的from写成form了

    SELECT COUNT(DISTINCT A,B)FROM t_TABLE