Veebster Veebster - 4 months ago 22
SQL Question

Combine splitted start and end time into one start and end time

I'm trying to combine some rows to one row.

My current query provides the following:

ID Name Dept Hours Date Start_time End_time
--- ---- ---- ----- ---- ----------- ----------
1 John 01-A 4:45 10-18-2016 10-18-2016 06:00:00 10-18-2016 10:45:00
1 John 01-A 3:15 10-18-2016 10-18-2016 11:15:00 10-18-2016 14:30:00


I need a
select
statement to show this result:

ID Name Dept Hours Date Start_time End_time
--- ---- ---- ----- ---- ----------- ----------
1 John 01-A 8:50 10-18-2016 10-18-2016 06:00:00 10-18-2016 14:30:00

Answer

Well assuming this is what you mean by Like data .

Select ID, Name, DEPT, SUM(HOURS), DATE, MIN(START_TIME),MAX(END_TIME)
from table
group by ID, Name, DEPT, DATE