将两列数据转换为行

时间:2019-12-23 19:09:42

标签: sql sql-server

数据(图像:数据)位于employeeID,Details和StartTime中。我想将数据转换为

EmployeeID,详细信息,开始时间 3735登录2019-12-17 06:30:57.500 3735午餐开始2019-12-17 12:16:11.373 3735午餐结束2019-12-17 12:46:26.807 3735注销2019-12-17 15:46:37.880 3862登录2019-12-20 06:29:13.423 3862 Lunchstart 2019-12-20 12:32:13.673 3862 LunchEnd 2019-12-20 13:02:46.623 3862注销2019-12-20 18:03:03.687 3862注销2019-12-20 18:03:03.703 3862登录2019-12-21 08:59:56.580 3862 Lunchstart 2019-12-21 11:48:03.080 3862午餐结束2019-12-21 12:16:05.160 3862注销2019-12-21 14:31:07.313 3862登录2019-12-22 08:02:33.117 3862 Lunchstart 2019-12-22 12:32:14.150 3862午餐时间2019-12-22 13:04:07.250 3862注销2019-12-22 15:00:09.700 3862登录2019-12-23 06:27:59.410 3862 Lunchstart 2019-12-23 11:58:41.693

除ID为StartTime以外,4列的EmployeeID,Login,注销,Lunchstart,LunchEnd各自的值。作为参考,请查看图像“结果”。

EmployeeID,登录名,LunchStart,LunchEnd,注销 3735,2019-12-17 06:30:57.500,2019-12-17 12:16:11.373,2019-12-17 12:16:11.373,2019-12-17 15:46:37.880 3862,2019-12-20 06:29:13.423,2019-12-20 12:32:13.673,2019-12-20 13:02:46.623,2019-12-20 18:03:03.687 等等

多谢建议。

致谢

Result

Data

0 个答案:

没有答案