表table有a、b、c三列,内容如下
a  b    c
1  bbb  ccc
2  bbb  ccc执行下面的语句后一行结果
select max(b),c from table group by c需要一个语句,返回上面那个结果有多少行。
类似count(*)
就这样无名列
1谢谢!!!

解决方案 »

  1.   


    select count(*)
    from (select max(b),c from table group by c)t
      

  2.   

    select max(b),c,count(*) from table group by c ??select count(*) from (select max(b) b,c from table group by c) a ??
      

  3.   


    create table #test(a int, b varchar(10), c varchar(10))
    insert into #test
    select 1,'bbb','ccc'
    union all select 2, 'bbb', 'ccc'select max(b),c from #test group by cselect @@rowcount-----------
    1(1 行受影响)
    --
      

  4.   


    select count(*)from (select max(b),c from table group by c)
      

  5.   

    select count(*) from table  where (b,c) in (select max(b),c from table group by c)