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

14 lines
402 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`.`workerBusinessDated`
AS SELECT `t`.`dated` AS `dated`,
`b`.`id` AS `businessFk`,
`b`.`workerFk` AS `workerFk`
FROM (
`vn`.`time` `t`
LEFT JOIN `vn`.`business` `b` ON(
`t`.`dated` BETWEEN `b`.`started` AND IFNULL(`b`.`ended`, `util`.`VN_CURDATE`())
)
)
WHERE `t`.`dated` > `util`.`VN_CURDATE`() + INTERVAL -2 year