CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`workerSpeedSaleTracking` AS SELECT `salesPreparedLastHour`.`warehouseFk` AS `warehouseFk`, `salesPreparedLastHour`.`code` AS `state`, `salesPreparedLastHour`.`workerCode` AS `workerCode`, sum(`salesPreparedLastHour`.`litros`) AS `sumaLitros`, min(`salesPreparedLastHour`.`created`) AS `started`, max(`salesPreparedLastHour`.`created`) AS `finished`, sum( IF( `salesPreparedLastHour`.`created` >= `util`.`VN_NOW`() + INTERVAL -1 HOUR, `salesPreparedLastHour`.`litros`, 0 ) ) AS `sumaLitrosLastHour`, cast( 60 * sum(`salesPreparedLastHour`.`litros`) / time_to_sec( timediff( max(`salesPreparedLastHour`.`created`), min(`salesPreparedLastHour`.`created`) ) ) AS decimal(10, 1) ) AS `litersByMinute`, `salesPreparedLastHour`.`departmentName` AS `departmentName` FROM `vn`.`salesPreparedLastHour` GROUP BY `salesPreparedLastHour`.`warehouseFk`, `salesPreparedLastHour`.`code`, `salesPreparedLastHour`.`workerCode`