2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost`
|
2024-01-15 11:31:03 +00:00
|
|
|
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`,
|
2024-01-15 11:31:03 +00:00
|
|
|
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`
|