select regisDate,count(1) cnt from tb group by regisDate
SELECT COUNT(*) FROM TB WHERE regisDate BETWEEN 2009-8-1 AND 2009-8-31
SELECT regisDate,COUNT(1)'注册人数' FROM TB GROUP BY regisDate
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)
select regisDate,count(1) cnt from tb where regisDate between '2009-08-01' and '2009-08-31' group by regisDatemodify
select 日期,count(1) as 数量 from tb group by 日期
select 人数=count(1) from 表 where regisDate>='2009-8-1' and regisDate<='2009-8-31' group by convert(varchar(10),regisDate,120)
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)
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)
[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]
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)
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)看来快不得
select count(1) '注册总人数' from tb where convert(varchar(8),regisDate,120) >='2009-08-01' and convert(varchar(8),regisDate,120)<='2009-08-31'
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
/* 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 */
WHERE regisDate BETWEEN 2009-8-1 AND 2009-8-31
GROUP BY regisDate
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)
group by convert(varchar(10),regisDate,120)
select convert(varchar(10),[day],120),count(1) from tb group by convert(varchar(10),[day],120)
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)
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]
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)
count(1) cnt
from tb
where regisDate between '2009-08-01' and '2009-08-31'
group by convert(char(10),regisDate,23)看来快不得
where convert(varchar(8),regisDate,120) >='2009-08-01' and convert(varchar(8),regisDate,120)<='2009-08-31'
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
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
*/