测试过了?if object_id('[Test]') is not null drop table [Test] go create table Test (high_ID int, high_datetime datetime) insert Test select 1,'2014/5/1 0:33:07' union all select 2,'2014/5/8 7:23:23' union all select 3,'2014/5/9 10:24:27' union all select 4,'2014/5/10 13:14:19' union all select 5,'2014/5/13 13:13:35' union all select 6,'2014/5/20 11:15:15' union all select 7,'2014/5/21 22:30:45' union all select 8,'2014/5/24 23:10:46' select convert(varchar,high_datetime,23) as '日期',count(1) as '统计' from test group by convert(varchar,high_datetime,23)日期 统计 ------------------------------ ----------- 2014-05-01 1 2014-05-08 1 2014-05-09 1 2014-05-10 1 2014-05-13 1 2014-05-20 1 2014-05-21 1 2014-05-24 1(所影响的行数为 8 行)
select max(high_datetime) as '日期', count(1) '统计' from [表名] group by Convert(varchar, [high_datetime],23)或者select high_datetime as '日期', count(1) '统计' from [表名] group by high_datetime这两个你都试试, 应该有一个合适你的
select [日期字段] '日期',
count(1) '统计'
from [表名]
group by [日期字段]
这样就可以了select Convert(varchar, [日期字段],23) '日期',
count(1) '统计'
from [表名]
group by Convert(varchar, [日期字段],23)
这样就可以了select Convert(varchar, [日期字段],23) '日期',
count(1) '统计'
from [表名]
group by Convert(varchar, [日期字段],23)
你好,谢谢你回答,我早上试一下,还是有点缺陷,麻烦版主在帮我改进一下,谢谢了!high_ID high_datetime
1 2014/5/1 0:33:07
2 2014/5/8 7:23:23
3 2014/5/9 10:24:27
4 2014/5/10 13:14:19
5 2014/5/13 13:13:35
6 2014/5/20 11:15:15
7 2014/5/21 22:30:45
8 2014/5/24 23:10:46
high_datetime的正确的时间格式是: 日期【空格】时间 例如:2014/5/8 7:23:23 或 2014/5/24 23:10:46 或 2014/5/9 10:24:27
麻烦改进一下,谢谢谢谢!
drop table [Test]
go
create table Test (high_ID int, high_datetime datetime)
insert Test
select 1,'2014/5/1 0:33:07' union all
select 2,'2014/5/8 7:23:23' union all
select 3,'2014/5/9 10:24:27' union all
select 4,'2014/5/10 13:14:19' union all
select 5,'2014/5/13 13:13:35' union all
select 6,'2014/5/20 11:15:15' union all
select 7,'2014/5/21 22:30:45' union all
select 8,'2014/5/24 23:10:46'
select convert(varchar,high_datetime,23) as '日期',count(1) as '统计' from test
group by convert(varchar,high_datetime,23)日期 统计
------------------------------ -----------
2014-05-01 1
2014-05-08 1
2014-05-09 1
2014-05-10 1
2014-05-13 1
2014-05-20 1
2014-05-21 1
2014-05-24 1(所影响的行数为 8 行)
select max(high_datetime) as '日期',
count(1) '统计'
from [表名]
group by Convert(varchar, [high_datetime],23)或者select high_datetime as '日期',
count(1) '统计'
from [表名]
group by high_datetime这两个你都试试, 应该有一个合适你的