现在有几十万的记录,其中一个字段是车牌号,这个车牌号的记录可能会有很多重复。比如车牌号为“ABCDE”的总共有多少个?请问能不能一次性的统计出所有不重复的车牌号的记录数?
比如:    车牌
   ABCDE
   12345
   ABCDE
   54321
   12345
   ABCDE如上加入数据行中有5条记录,车牌号的记录如上,我现在希望得到如下结果   车牌          个数
   ABCDE           3
   12345           2
   54321           1
请问该如何写sql语句呢?(最好是用1条语句搞定)
      

解决方案 »

  1.   

    select 车牌,Count(*) from 表 group by 车牌
      

  2.   

    select count(*), 车牌 from table1 group by 车牌 order by count(*) desc
      

  3.   

    select count(*) as 个数, 车牌 from table1 group by 车牌 order by count(*) desc
      

  4.   


    2楼正解统计一个:
    select 车牌,Count(*) from 表 where 车牌='ABCDE'
      

  5.   

    select count(*) as 个数, 车牌 from table1 group by 车牌 order by count(*) desc
    用group by 就行了
      

  6.   

    select count(*) as 个数, 车牌 from table1 group by 车牌 order by count(*) desc
      

  7.   

    select 车牌,Count(*) from 表 group by 车牌 having 车牌='aaaaa'
      

  8.   

    select distinct 车牌,count(车牌) from 表
      

  9.   


    select 车牌,Count(*) from 表 group by 车牌
    var a=from p in ***
          where Group By 车牌="***" 
          select(count(P));
      

  10.   

    select 车牌,Count(*) from 表 group by 车牌
      

  11.   

    我也过来接点分:select 车牌,count(车牌) as 数量 from tbl group by 车牌 
      

  12.   

    select count(*) as 个数, 车牌 from table1 group by 车牌 order by count(*) desc
      

  13.   

    谢谢大家,select count(*) as 个数, 车牌 from table1 group by 车牌 order by count(*) desc
    这条sql最完美