salix/db/routines/vn/views/productionVolume_LastHour.sql

12 lines
441 B
SQL

CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`productionVolume_LastHour`
AS SELECT cast(
sum(`productionVolume`.`cm3` / 1000000) AS decimal(10, 0)
) AS `m3`,
`productionVolume`.`warehouseFk` AS `warehouseFk`
FROM `vn`.`productionVolume`
WHERE `productionVolume`.`created` > `util`.`VN_NOW`() + INTERVAL -1 HOUR
AND `productionVolume`.`warehouseFk` IN (1, 44, 60)
GROUP BY `productionVolume`.`warehouseFk`