select concat('UPDATE RECEIPT SET KEY_EMPLOYEE = ',KEY_EMPLOYEE,' WHERE ID_INTERNAL =',KEY_RECEIPT, ';') as "" 
from RECEIPT_PRINT_VERSION WHERE ID_INTERNAL IN (SELECT ID_INTERNAL FROM RECEIPT_PRINT_VERSION GROUP BY KEY_RECEIPT HAVING WHEN_CREATED = MIN(WHEN_CREATED));
 
 