表结构:id   c_date  
1    2012-05-01
2    2012-05-01
3    2012-05-03
4    2012-05-07
5    2012-05-07我需要得到不同的日期的总次数,也就是说1号这一天2次,3号为一次,7号为两次,那么怎样得到计数是5次呢?
用SQL语句怎么写呢?望各位大侠赐教!感谢!

解决方案 »

  1.   

    select sum(cnt) as cnt 
    from (select count(1) as cnt from t group by c_date) as x
      

  2.   

    select c_date,count(*) from table group by c_date union all
    select 'date',count(*) from table 
      

  3.   

    select count(distinct c_date) from table_name
      

  4.   


    select count(distinct c_date) as [count] from tb
      

  5.   

    select count(*) as [count] from tb这个倒是可以得到5,不知道是不是楼主要的答案呢?
      

  6.   


    select count(distinct c_date ) as c_date from tb