Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.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 server 2008 SQL Server 2008每个用户每个状态的分组时间戳_Sql Server 2008_Timestamp_Grouping_Sql Server 2014 - Fatal编程技术网

Sql server 2008 SQL Server 2008每个用户每个状态的分组时间戳

Sql server 2008 SQL Server 2008每个用户每个状态的分组时间戳,sql-server-2008,timestamp,grouping,sql-server-2014,Sql Server 2008,Timestamp,Grouping,Sql Server 2014,我已经在谷歌上搜索了3天,并通过stackoverflow进行了搜索。我有一点挑战。这就是问题/挑战 我有如下原始数据: Employee Id Pay Date Time In Time Out Cost Center 3 91458 7-8-2015 7-8-2015 10:13 7-8-2015 10:27 3103 91458 7-8-2015 7-8-2015 10:27

我已经在谷歌上搜索了3天,并通过stackoverflow进行了搜索。我有一点挑战。这就是问题/挑战

我有如下原始数据:

Employee Id    Pay Date    Time In           Time Out         Cost Center 3
   91458       7-8-2015    7-8-2015 10:13    7-8-2015 10:27    3103
   91458       7-8-2015    7-8-2015 10:27    7-8-2015 11:20    2004
   91458       7-8-2015    7-8-2015 11:20    7-8-2015 11:32    1001
   91458       7-8-2015    7-8-2015 11:32    7-8-2015 12:04    2004
   91458       7-8-2015    7-8-2015 12:04    7-8-2015 12:06    2004
   91458       7-8-2015    7-8-2015 12:06    7-8-2015 12:06    2004
   91458       7-8-2015    7-8-2015 12:06    7-8-2015 12:28    2004
   91458       7-8-2015    7-8-2015 14:01    7-8-2015 14:33    1002
但我需要的输出是:

Employee Id   Pay Date    Time In          Time Out        Cost Center 3
   91458      7-8-2015    7-8-2015 10:13   7-8-2015 10:27      3103
   91458      7-8-2015    7-8-2015 10:27   7-8-2015 11:20      2004
   91458      7-8-2015    7-8-2015 11:20   7-8-2015 11:32      1001       
   91458      7-8-2015    7-8-2015 11:32   7-8-2015 12:28      2004
   91458      7-8-2015    7-8-2015 14:01   7-8-2015 14:33      1002
这是在SQL Server 2008上进行的,但数据将在40天内迁移到SQL Server 2014计算机,因此SQL Server 2014解决方案也很有用

问候,,
Gary

您是否介意详细说明这两个数据集之间的差异以及您迄今为止尝试过的方法?是的。在顶部,您可以看到成本中心3,其中包含2004年。关于第二组,从2015年7月8日11:32开始,你会看到4行代码为2004,我需要将其分组,因此我得到1行,时间为2015年7月8日11:32,但最后一个成本中心2004的时间为2015年7月8日12:28。我已经尝试过排名、密集排名、模仿落后和领先。以及加入数据在它自己。谢谢你的帮助。。200X为生产状态,100X为braek状态,310X为DND状态。