please help.. please see example data below and the desired output..
Data:
EmployeeID Date In Out
00001 01/01/2018 | 07:00 AM
Use PIVOT:
WITH Src AS
(
SELECT * FROM (VALUES
('00001' ,'01/01/2018', '07:00 AM', '05:00 PM'),
('00001' ,'01/02/2018', '07:00 AM', '05:00 PM'),
('00001' ,'01/03/2018', '07:00 AM', '05:00 PM'),
('00002' ,'01/01/2018', '07:00 AM', '05:00 PM'),
('00002' ,'01/02/2018', '07:00 AM', '05:00 PM'),
('00002' ,'01/03/2018', '07:00 AM', '05:00 PM')) T(EmployeeID,[Date],[In],[Out])
)
SELECT * FROM
(SELECT EmployeeID, [Date], [In]+' - '+[Out] [In] FROM Src) T
PIVOT (MAX([In]) FOR [Date] IN ([01/01/2018],[01/02/2018],[01/03/2018])) AS P