Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 选择“查询工作异常”_Sql_Sql Server_Sql Server 2008_Tsql_Sql Server 2012 - Fatal编程技术网

Sql 选择“查询工作异常”

Sql 选择“查询工作异常”,sql,sql-server,sql-server-2008,tsql,sql-server-2012,Sql,Sql Server,Sql Server 2008,Tsql,Sql Server 2012,我对sql中日期时间数据的逻辑运算符的性质感到困惑 在我的数据库的表RecordDateTime中,保存方式如下: 2014-04-09 15:28:32.000 我正在根据此查询检索: select * from [GPSDB].[dbo].[Coordinates] where IMEI= '354400055967495' and RecordedDateTime >= '2014-04-09 15:28:32.000' and RecordedD

我对sql中日期时间数据的逻辑运算符的性质感到困惑

在我的数据库的表RecordDateTime中,保存方式如下:

2014-04-09 15:28:32.000
我正在根据此查询检索:

select 
    * 
from [GPSDB].[dbo].[Coordinates] 
where IMEI= '354400055967495' 
    and RecordedDateTime >= '2014-04-09 15:28:32.000' 
    and RecordedDateTime <= '2014-04-09 15:39:20.000'
选择
* 
从[GPSDB].[dbo].[坐标]
其中IMEI='354400055967495'
和RecordedDateTime>=“2014-04-09 15:28:32.000”
记录的日期时间='2014-04-09 15:28'

和RecordedDateTime日期时间数据
2014-04-09 15:28:32.000
有两部分日期部分
2014-04-09
和时间部分
15:28:32.000

所以当你说

RecordedDateTime>='2014-04-09 15:28:32.000'和RecordedDateTime='2014-04-09'

如果你不给我们看一些数据,记录的最新时间很难说。我怀疑四个条目中有三个的时间戳在15:39:00和15:39:20之间。这就是全部。当然,如果从第二个时间戳中删除秒数,则不会返回结果集。能否提供结果集或其中的日期部分。
select 
    * 
from [GPSDB].[dbo].[Coordinates] 
where IMEI = '354400055967495'
    and RecordedDateTime >= '2014-04-09 15:28' 
    and RecordedDateTime <= '2014-04-09 15:39:20.000'
RecordedDateTime >= '2014-04-09' 
and RecordedDateTime <= '2014-04-09'