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

24 lines
692 B
MySQL
Raw Normal View History

CREATE OR REPLACE DEFINER=`vn-admin`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`productionVolume`
AS SELECT HOUR(`e`.`created`) AS `hora`,
MINUTE(`e`.`created`) AS `minuto`,
IFNULL(
`p`.`volume`,
IFNULL(`p`.`width` * `p`.`height` * `p`.`depth`, 94500)
) AS `cm3`,
`t`.`warehouseFk` AS `warehouseFk`,
`e`.`created` AS `created`
FROM (
(
(
`vn`.`expedition` `e`
LEFT JOIN `vn`.`packaging` `p` ON(`p`.`id` = `e`.`packagingFk`)
)
JOIN `vn`.`ticket` `t` ON(`t`.`id` = `e`.`ticketFk`)
)
JOIN `vn`.`client` `c` ON(`c`.`id` = `t`.`clientFk`)
)
WHERE `e`.`created` BETWEEN `util`.`VN_CURDATE`() AND `util`.`dayend`(`util`.`VN_CURDATE`())
AND `c`.`isRelevant` <> 0