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

12 lines
441 B
MySQL
Raw Normal View History

2024-08-20 08:06:10 +00:00
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`