( select 时间, convert(int, 第二列) as 小时, 数量 from 表格)
select 时间, 小时, sum(数量)
from data
group by 时间, 小时
select '2011-01-23 00:23:34' 日期 ,'a' 内容 into #temp unionselect '2011-01-23 00:35:31','a' union
select '2011-01-23 02:44:34','a' union
select '2011-01-23 02:52:12','b' union
select '2011-01-23 04:23:34','c' union
select '2011-01-23 04:11:03','d' union
select '2011-01-23 04:05:34','c' union
select '2011-01-23 05:23:21','b'
select convert(varchar(13),日期,120),count(内容)
from #temp
group by convert(varchar(13),日期,120)
select convert(varchar(13),日期,120),count(distinct 内容)
from #temp
group by convert(varchar(13),日期,120)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)