BEGIN #Routine body goes here... INSERT INTO EMS_PM_STORAGE ( AMOID, GP_BEGIN_TIME, EMS_RECORD_TIME, ZDC_L_LODA ) SELECT epl.AMOID, epl.GP_BEGIN_TIME, TIMESTAMPDIFF( MINUTE, epl.GP_BEGIN_TIME, MAX(epl.LOG_TIME) ) RECORD_TIME2, TIMESTAMPDIFF( MINUTE,…