I understand that a normal UPDATE xxx FROM does not support the GROUP BY clause but for the life of me I can not figure out how to modify the below code to be in a single UPDATE statement. I now I could break it out into multiple update statements and do a subquery on each assignment but the over head on that is large and would like to avoid that. UPDATE #DriverTimes SET StartTime = MIN(dte.StrtTm), EndTime = MAX(dte.Endtm), #DriverTimes.StartBreak = MIN(dte.StartBreak), StartDateTime = (CONVERT(DATETIME, CONVERT(CHAR(8), dte.DtWrkd, 112) + ' ' + LEFT(RIGHT('0' + MIN(dte.StrtTm), 4), 2) + ':' + RIGHT(MIN(dte.StrtTm), 2))), EndDateTime = (CONVERT(DATETIME, CONVERT(CHAR(8), dte.DtWrkd, 112) + ' ' + LEFT(RIGHT('0' + MIN(dte.EndTm), 4),2) + ':' + RIGHT(MIN(dte.EndTm), 2))) FROM dbo.spr_DriverTimeEntry AS dte WITH (NOLOCK) WHERE DriverID = DrvrID AND DateWorked = DtWrkd AND PryllID IN ( 1, 22, 1013, 1014 ) GROUP BY DrvrID, Dtwrkd, PryllID;
-- If I get used to envying others...Those things about my self I pride will slowly fade away.-Stellvia