怎样统计出12月,那天添加的记录最多。

解决方案 »

  1.   

    select top 1 convert(char(10),datacol,120)
    from t
    where datepart(m,datecol) =12
    group by convert(char(10),datacol,120)
    order by count(1) desc
      

  2.   

    select top 1 日期=convert(char(10),datecol,120), 添加的记录数=count(1)
    from t
    where datepart(mm,datecol) = 12
    group by convert(char(10),datecol,120)
    order by 添加的记录数 desc
      

  3.   

    select datepart(dy,date),count(1) as 记录
    from T 
    where convert(varchar(7),date,120)='2007-12'
    group by datepart(dy,date)
      

  4.   

    declare @tb table (id int,col varchar(10),dt datetime)
    insert into @tb select 1,'a','2008-12-01'
    insert into @tb select 2,'a','2008-12-01'
    insert into @tb select 3,'a','2008-12-01'
    insert into @tb select 4,'a','2008-12-02'
    insert into @tb select 5,'a','2008-12-02'
    insert into @tb select 6,'a','2008-12-03'
    insert into @tb select 7,'a','2008-12-03'
    insert into @tb select 8,'a','2008-12-03'
    insert into @tb select 9,'a','2008-12-05'
    insert into @tb select 10,'a','2008-12-05'
    insert into @tb select 11,'a','2008-12-05'
    insert into @tb select 12,'a','2008-12-05'select top 1 convert(varchar(10),dt,120)as '日期',count(1) as cn 
    from @tb where datename(mm,dt)=12
    group by convert(varchar(10),dt,120)
    order by cn desc日期 cn
    2008-12-05 4
      

  5.   


    上面是统计本月。。
    下面统计12月;
    select top 1 convert(varchar(10),时间字段,120) from 表名
    where datepart(mm,时间字段)=12 group by convert(varchar(10),时间字段,120)
    order by count(1) desc  
      

  6.   

    怎样统计出12月,那天添加的记录最多。select top 1 convert(varchar(10),日期,120) 日期 , count(*) cnt from tb group by convert(varchar(10),日期,120) order by cnt desc
      

  7.   

    select top 1 datatime,count(primarykey) as recordcount from tb group by datatime order by recordcount