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

18 lines
511 B
MySQL
Raw Normal View History

CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`exchangeInsuranceOut`
AS SELECT `p`.`received` AS `received`,
sum(`p`.`divisa`) AS `divisa`,
sum(`p`.`divisa`) / sum(`p`.`amount`) AS `rate`
FROM (
(
`vn`.`payment` `p`
2024-03-05 09:25:23 +00:00
JOIN `vn`.`accounting` `a` ON(`a`.`id` = `p`.`bankFk`)
)
2024-03-05 09:25:23 +00:00
JOIN `vn`.`accountingType` `at2` ON(`at2`.`id` = `a`.`accountingTypeFk`)
)
WHERE `p`.`currencyFk` = 2
AND `at2`.`code` = 'wireTransfer'
AND `p`.`supplierFk` <> 2213
GROUP BY `p`.`received`