有一个表有如下数据ID  TelNO  CreateTime  EndTime
0   12345  2006-7-1    2006-7-1
1   12455  2006-8-2    2006-8-2
2   12345  2006-7-5    2006-7-5
3   12450  2006-8-3    2006-8-3
4   12345  2006-7-9    2006-7-9
5   12455  2006-8-2    2006-8-2如何用一条SQL实现获得取得各不同TelNO 的记录数 希望得到的是TelNO   Count
12345   3
12455   2
12450   1

解决方案 »

  1.   

    select TelNO,count(*) from tablegroup by type
      

  2.   

    select telno,count(*) from 表 group by telno
      

  3.   

    select telno,count(1) from 表 group by telno
      

  4.   

    select TelNO,Count = count(1) from yTable group by TelNO
      

  5.   

    Select TelNo,Count(*) as [Count] from 你的表名 group by TelNo
      

  6.   

    Select TelNo,Count(1) as [Count] from @t group by telno order by [count] desc
    Select TelNo,[Count]=Count(*) from @t group by telno order by [count] desc