Попробуйте эту опору
;WITH CTE(ID,[DATE], EMPID,[TIME], REMARKS)
AS
(
SELECT 1 ,'20/09/2018', 9001,'7:30' ,'This will be the In_1 as it is the first TIME-IN in for EMPID=9001' UNION ALL
SELECT 2 ,'20/09/2018', 9001,'7:40' ,'This will be the In_2 as it is the second TIME-IN for EMPID=9001' UNION ALL
SELECT 3 ,'20/09/2018', 9001,'7:50' ,' Not included' UNION ALL
SELECT 4 ,'20/09/2018', 9001,'17:10',' This will be the Out_1 as it is the first TIME-OUT for EMPID=9001' UNION ALL
SELECT 5 ,'20/09/2018', 9001,'17:50',' This will be the Out_2 as it is the second TIME-OUT for EMPID=9001' UNION ALL
SELECT 6 ,'20/09/2018', 9001,'18:00',' Not included' UNION ALL
SELECT 7 ,'20/09/2018', 9002,'7:20' ,' This will be the In_1 as it is the first TIME-IN in for EMPID=9002' UNION ALL
SELECT 8 ,'20/09/2018', 9002,'7:21' ,' This will be the In_2 as it is the second TIME-IN for EMPID=9002' UNION ALL
SELECT 9 ,'20/09/2018', 9002,'18:00',' This will be the Out_1 as it is the first TIME-OUT for EMPID=9002' UNION ALL
SELECT 10,'20/09/2018', 9003,'7:00' ,' This will be the In_1 as it is the first TIME-IN in for EMPID=9003' UNION ALL
SELECT 11,'20/09/2018', 9003,'17:10',' This will be the Out_1 as it is the first TIME-OUT for EMPID=9003' UNION ALL
SELECT 11,'20/09/2018', 9003,'17:12',' This will be the Out_2 as it is the second TIME-OUT for EMPID=9003' UNION ALL
SELECT 11,'20/09/2018', 9003,'17:15',' Not included'
)
SELECT [DATE], EMPID,[In_1],[In_2],[Out_1],[Out_2] FROM
(
SELECT [DATE], EMPID,[TIME]
,MAX(CASE WHEN CHARINDEX('In_1',REMARKS)>0 THEN 'In_1'
WHEN CHARINDEX('In_2',REMARKS)>0 THEN 'In_2'
WHEN CHARINDEX('Out_1',REMARKS)>0 THEN 'Out_1'
WHEN CHARINDEX('Out_2',REMARKS)>0 THEN 'Out_2'
ELSE 'NA' END) AS Details
FROM CTE
GROUP BY [DATE], EMPID,[TIME]
)dt
PIVOT
(
MAX([TIME]) FOR Details IN ([In_1],[In_2],[Out_1],[Out_2])
)pvt
Результат
DATE EMPID In_1 In_2 Out_1 Out_2
-------------------------------------------------
20/09/2018 9001 7:30 7:40 17:10 17:50
20/09/2018 9002 7:20 7:21 18:00 NULL
20/09/2018 9003 7:00 NULL 17:10 17:12