2024-07-22 09:52:42 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost`
|
2024-01-15 11:31:03 +00:00
|
|
|
SQL SECURITY DEFINER
|
|
|
|
VIEW `vn`.`NewView`
|
|
|
|
AS SELECT `c`.`id` AS `clientFk`,
|
|
|
|
max(`t`.`shipped`) AS `lastShipped`,
|
|
|
|
`pc`.`notBuyingMonths` AS `notBuyingMonths`
|
|
|
|
FROM (
|
|
|
|
(
|
|
|
|
`vn`.`client` `c`
|
|
|
|
JOIN `vn`.`productionConfig` `pc`
|
|
|
|
)
|
|
|
|
LEFT JOIN `vn`.`ticket` `t` ON(
|
|
|
|
`c`.`id` = `t`.`clientFk`
|
|
|
|
AND `t`.`shipped` < `util`.`VN_CURDATE`() + INTERVAL - `pc`.`rookieDays` DAY
|
|
|
|
)
|
|
|
|
)
|
|
|
|
GROUP BY `c`.`id`
|
|
|
|
HAVING `lastShipped` IS NULL
|
|
|
|
OR `lastShipped` < `util`.`VN_CURDATE`() + INTERVAL - `notBuyingMonths` MONTH
|