比如我想输出
工作人员 总数
a        3
b        3
c        3
应该怎样写?

解决方案 »

  1.   

    select 工作人员,count(*)over() as 总数 from tb
      

  2.   

    select 工作人员,总数 =count(*) from tablename group by 工作人员
      

  3.   


    declare @table table (工作人员 varchar(1))
    insert into @table
    select 'a' union all
    select 'b' union all
    select 'c'select *,总数=(select count(*) from @table)from @table/*
    工作人员 总数
    ---- -----------
    a    3
    b    3
    c    3
    */刚才理解差了。