Got a big of a mind stopping question. Need to flatted the sql result set from multiple records per EMPLOYEECODE to one. Keeping the min STARTIME and showing the max ENDTIME for each record. Hope the images are explanatory. Would love to have an idea how to deliver it. THANKS!
CodePudding user response:
Assuming there are no shifts that go past midnight for a given date you could use this:
SELECT EMPLOYEECODE, SHIFTDATE, MIN(STARTTIME),MAX(STOPTIME),MIN(START_TIME),MAX(STOP_TIME) FROM TABLENAME GROUP BY EMPLOYEECODE;