日期:2014-05-17  浏览次数:21142 次

SQL Server 如何提取整点时间的记录,查询语句怎么写
数据库内容如下,只是一部分

  "H_Date" "AlarmingPoint" "AlarmValue"
2007-12-22 00:00:23 "p1" "2.454 "
2007-12-22 10:00:00 "A1" "23.32" (*)
2007-12-22 10:55:00 "p1" "2.454 "
2007-12-22 11:00:00 "A1" "23.32" (*)
2007-12-22 12:00:00 "p1" "2.454 " (*)
2007-12-22 13:10:00 "A1" "23.32"
2007-12-22 13:10:01 "p1" "2.454 "
2007-12-22 14:23:20 "A1" "23.32"
2007-12-22 15:00:00 "p1" "2.454 " (*)
2007-12-22 16:00:08 "A1" "23.32"

如何提取整点时间的记录,就是后面有 (*)的记录,查询语句怎么写

------解决方案--------------------
SQL code
create table tb(H_Date datetime ,AlarmingPoint varchar(10),AlarmValue varchar(10))
insert into tb values('2007-12-22 00:00:23', 'p1', '2.454') 
insert into tb values('2007-12-22 10:00:00', 'A1', '23.32') 
insert into tb values('2007-12-22 10:55:00', 'p1', '2.454') 
insert into tb values('2007-12-22 11:00:00', 'A1', '23.32') 
insert into tb values('2007-12-22 12:00:00', 'p1', '2.454') 
insert into tb values('2007-12-22 13:10:00', 'A1', '23.32') 
insert into tb values('2007-12-22 13:10:01', 'p1', '2.454') 
insert into tb values('2007-12-22 14:23:20', 'A1', '23.32') 
insert into tb values('2007-12-22 15:00:00', 'p1', '2.454') 
insert into tb values('2007-12-22 16:00:08', 'A1', '23.32') 
go
select * from tb where datepart(mi,h_date) = 0 and datepart(ss,h_date) = 0
drop table tb
/*
H_Date                  AlarmingPoint AlarmValue
----------------------- ------------- ----------
2007-12-22 10:00:00.000 A1            23.32
2007-12-22 11:00:00.000 A1            23.32
2007-12-22 12:00:00.000 p1            2.454
2007-12-22 15:00:00.000 p1            2.454

(4 行受影响)
*/