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

28 lines
781 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`.`saleVolume_Today_VNH`
AS SELECT `t`.`nickname` AS `Cliente`,
`p`.`name` AS `Provincia`,
2024-04-24 07:05:29 +00:00
`c`.`name` AS `Pais`,
cast(sum(`sv`.`volume`) AS decimal(5, 1)) AS `volume`
FROM (
(
(
(
(
`vn`.`saleVolume` `sv`
JOIN `vn`.`ticket` `t` ON(`t`.`id` = `sv`.`ticketFk`)
)
JOIN `vn`.`address` `a` ON(`a`.`id` = `t`.`addressFk`)
)
JOIN `vn`.`province` `p` ON(`p`.`id` = `a`.`provinceFk`)
)
JOIN `vn`.`country` `c` ON(`c`.`id` = `p`.`countryFk`)
)
JOIN `vn`.`warehouse` `w` ON(`w`.`id` = `t`.`warehouseFk`)
)
WHERE `w`.`name` = 'VNH'
AND `t`.`shipped` BETWEEN `util`.`VN_CURDATE`() AND `util`.`dayend`(`util`.`VN_CURDATE`())
GROUP BY `t`.`nickname`,
`p`.`name`