你是要得到行数,要分组干什么?去掉分组!
select @@rowcount=count(*) 
from a 
where ( a.a >= '2003-01-01' ) and
      ( a.a < '2004-01-01' )

解决方案 »

  1.   

    select count(distinct a , b ) 
    from a 
    where ( a.a >= '2003-01-01' ) and
          ( a.a < '2004-01-01' )
      

  2.   

    select count(*) from (
    select count(*) 
    from a 
    where ( a.a >= '2003-01-01' ) and
          ( a.a < '2004-01-01' )
    group by a.a,
             a.b) as A
      

  3.   

    select count(*) from (
    select count(*) as cnt 
    from a 
    where ( a.a >= '2003-01-01' ) and
          ( a.a < '2004-01-01' )
    group by a.a,
             a.b) as A
      

  4.   

    up
    我也来一个
    select count(*) from (
    select distinct a.a,a.b 
    from a 
    where ( a.a >= '2003-01-01' ) and
          ( a.a < '2004-01-01' ))
    在来一个
    select count(*) 
      from( select a.a,a.b 
              from a 
             where ( a.a >= '2003-01-01' ) and ( a.a < '2004-01-01' ) 
          group by a.a, a.b
          ) as A
      

  5.   

    pbsql(风云):
    服务器: 消息 170,级别 15,状态 1,行 1
    第 1 行: '=' 附近有语法错误。black_snail(●龙飞虎○):
    服务器: 消息 170,级别 15,状态 1,行 1
    第 1 行: ',' 附近有语法错误。分组是必须要加的,而且数据是符合要求的。
    或者第一条语句可以写为这样:
    select b
    from a
    where ( a.a >= '2003-01-01' ) and
          ( a.a < '2004-01-01' )
    group by a.a,
             a.b
    结果集的行数也是1445,
    现在的问题是用一条语句得到1445。