salix/db/routines/sage/views/clientLastTwoMonths.sql

13 lines
490 B
MySQL
Raw Normal View History

CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `sage`.`clientLastTwoMonths`
AS SELECT `vn`.`invoiceOut`.`clientFk` AS `clientFk`,
`vn`.`invoiceOut`.`companyFk` AS `companyFk`
FROM `vn`.`invoiceOut`
WHERE `vn`.`invoiceOut`.`issued` > `util`.`VN_CURDATE`() - INTERVAL 2 MONTH
UNION
SELECT `vn`.`receipt`.`clientFk` AS `clientFk`,
`vn`.`receipt`.`companyFk` AS `companyFk`
FROM `vn`.`receipt`
WHERE `vn`.`receipt`.`payed` > `util`.`VN_CURDATE`() - INTERVAL 2 MONTH