select convert(varchar(13), auditdate),
count(1) from dailyscore
group by convert(varchar(13), auditdate)
order by convert(varchar(13), auditdate)
count(1) from dailyscore
group by convert(varchar(13), auditdate)
order by convert(varchar(13), auditdate)
count(1) from dailyscore
group by convert(varchar(13), auditdate,120)
order by convert(varchar(13), auditdate,120)
select convert(varchar(13),auditdate,120)+':00',
count(1) from dailyscore
group by convert(varchar(13),auditdate,120)
order by convert(varchar(13),auditdate,120)
convert(varchar(13),auditdate,120)
不过我有个问题(原来数据不多,所以没有注意到),查询的结果是:
2008-04-17 17:00 574
2008-04-17 18:00 597
2008-04-17 19:00 617
2008-04-17 20:00 641
2008-04-17 21:00 668
2008-04-17 22:00 627
2008-04-17 23:00 598
2008-04-18 12:00 547
2008-04-18 13:00 560
2008-04-18 14:00 567
2008-04-18 15:00 578
2008-04-18 16:00 589
2008-04-18 17:00 599
2008-04-18 18:00 609
2008-04-18 19:00 622
2008-04-18 20:00 634
2008-04-18 21:00 644
2008-04-18 22:00 619
2008-04-18 23:00 606
2008-04-19 12:00 229
2008-04-19 13:00 247
2008-04-19 14:00 260
2008-04-19 15:00 274
2008-04-19 16:00 280
2008-04-19 17:00 287
2008-04-19 18:00 296
2008-04-19 19:00 308
2008-04-19 20:00 317
2008-04-19 21:00 325
你可以注意到时间是有问题的,23:00以后本来应该是00:00,可是这个query得到的结果是12:00.
虽然帖子已经结了,有没有谁还是能指点一下?谢谢。