按小时排序:datepart(hour,d_time)
select datepart(hour,d_time) as dtime,n_amount
from 表
where n_server_id=XX
and d_time>='2012-09-13'
group by datepart(hour,d_time),n_amount
按照分钟排序:20分钟一次的
select convert(varchar(10),d_time,120) as '日期',datepart(hour,d_time) as '小时',n_amount as '记录'
from GAME_ONLINE_STAT
where n_server_id=71
and d_time>='2012-09-13'+' 00:00:00'
and d_time<'2012-09-14'+' 23:59:59'
group by convert(varchar(10),d_time,120),datepart(hour,d_time),datepart(mi,d_time)/20,n_amount
order by datepart(hour,d_time)