比如,从8月1日到8月31日,每天注册的人数。数据库里有regisDate项。谢谢。

解决方案 »

  1.   

    select regisDate,count(1) cnt from tb group by regisDate
      

  2.   

    SELECT COUNT(*) FROM TB
    WHERE regisDate BETWEEN 2009-8-1 AND 2009-8-31
      

  3.   

    SELECT regisDate,COUNT(1)'注册人数' FROM TB
    GROUP BY regisDate
      

  4.   

    select 
      convert(varchar(10),regisDate,120) as regisDate,
      count(distinct [user])
    from
      tb
    where
      convert(varchar(10),regisDate,120) between '2009-08-01' and '2009-08-31'
    group by
      convert(varchar(10),regisDate,120)
      

  5.   

    select regisDate,count(1) cnt from tb where regisDate between '2009-08-01' and '2009-08-31' group by regisDatemodify
      

  6.   

    select 日期,count(1) as 数量 from tb group by 日期
      

  7.   

    select 人数=count(1) from 表 where regisDate>='2009-8-1' and regisDate<='2009-8-31'
    group by convert(varchar(10),regisDate,120) 
      

  8.   

    select [day],count(1) from tb group by [day]
    select convert(varchar(10),[day],120),count(1) from tb group by convert(varchar(10),[day],120)
      

  9.   

    select 
      convert(varchar(10),regisDate,120) as regisDate,
      count(1) as 人数
    from
      tb
    where
      convert(varchar(10),regisDate,120) between '2009-08-01' and '2009-08-31'
    group by
      convert(varchar(10),regisDate,120)
      

  10.   

    [code=SQLselect 
      convert(varchar(10),regisDate,120) as regisDate, 
      count(1) as 人数 
    from 
      tb 
    where 
      convert(varchar(10),regisDate,120) between '2009-08-01' and '2009-08-31' 
    group by 
      convert(varchar(10),regisDate,120) ][/code]
      

  11.   

    select 
      convert(varchar(10),regisDate,120) as regisDate, 
      count(1) as 人数 
    from 
      tb 
    where 
      convert(varchar(10),regisDate,120) between '2009-08-01' and '2009-08-31' 
    group by 
      convert(varchar(10),regisDate,120) 
      

  12.   

    select convert(char(10),regisDate,23) regisDate,
       count(1) cnt 
    from tb 
    where regisDate between '2009-08-01' and '2009-08-31' 
    group by convert(char(10),regisDate,23)看来快不得
      

  13.   

    select count(1) '注册总人数' from tb
    where convert(varchar(8),regisDate,120) >='2009-08-01' and convert(varchar(8),regisDate,120)<='2009-08-31'
      

  14.   

    declare @i int
    set @i= 20080801
    create table #a (regdate int, regcount int)
    while @i<20080832
    begin
    insert into #a select @i,count(1) from tb where regisDate=convert(varchar(10),@i) 
    set @i = @i+1
    end
    select * from #a drop table #a
      

  15.   

    /*
    Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86)   Jul  9 2008 14:43:34   Copyright (c) 
    1988-2008 Microsoft Corporation  Enterprise Evaluation Edition on Windows NT 5.1 <X86> 
    (Build 2600: Service Pack 3) 
     愿和大家共同进步
    如有雷同、实属巧合
    ●●●●●2009-09-03 14:10:36.077●●●●●
     ★★★★★soft_wsx★★★★★
    */
    if object_id('tb') is not null drop table tb
      create table tb(rq varchar(10),name varchar(20))
    go
    insert tb
     select
    '2009-9-1', 'tom' 
    union all select '2009-9-1', 'jack' 
    union all select '2009-9-1', 'tom' 
    union all select '2009-9-2', 'bill' 
    union all select '2009-9-2', 'tim' 
    union all select '2009-9-3', 'john' 
    union all select '2009-9-4', 'tom' 
    union all select '2009-9-4', 'kite' 
    union all select '2009-9-4', 'john' 
    union all select '2009-9-5', 'tom'select rq as 日期,COUNT(distinct(name)) as 登录用户数 from tb(nolock)
      group by rq
      
    /*
    日期 登录用户数
    2009-9-1 2
    2009-9-2 2
    2009-9-3 1
    2009-9-4 3
    2009-9-5 1
    */select rq as 日期,COUNT(name) as 登录用户数 from tb(nolock)
      group by rq
    /*
    日期 登录用户数
    2009-9-1 3
    2009-9-2 2
    2009-9-3 1
    2009-9-4 3
    2009-9-5 1
    */
      

  16.   

    按日期分组!用count(1)统计记录数就可以了!