select convert(varchar(10),logintime,120), 注册人数=sum(case when 类型='注册' then 1 end), 登录人数=sum(case when 类型='登录' then 1 end), 0时=sum(case when datepart(hh,logintime)=0 then 1 end), 1时=sum(case when datepart(hh,logintime)=1 then 1 end), ............. 11时=sum(case when datepart(hh,logintime)=11 then 1 end) from tb group by convert(varchar(10),logintime,120)
select sum(登陆人数) from tb group by convert(varchar(13),logintime) --???表字段都有哪些啊?我乱扯1个先
select count(*) from tb where logintime between '2011-8-2' and '2011-8-9' group by convert(varchar(13),logintime,120) --???
select convert(varchar(10),logintime,120), count(1) as 登录人数 from tb group by convert(varchar(10),logintime,120)
注册人数=sum(case when 类型='注册' then 1 end),
登录人数=sum(case when 类型='登录' then 1 end),
0时=sum(case when datepart(hh,logintime)=0 then 1 end),
1时=sum(case when datepart(hh,logintime)=1 then 1 end),
.............
11时=sum(case when datepart(hh,logintime)=11 then 1 end)
from tb group by convert(varchar(10),logintime,120)
--???表字段都有哪些啊?我乱扯1个先
group by convert(varchar(13),logintime,120)
--???
convert(varchar(10),logintime,120),
count(1) as 登录人数
from
tb
group by
convert(varchar(10),logintime,120)