18 lines
509 B
SQL
18 lines
509 B
SQL
CREATE OR REPLACE DEFINER=`vn`@`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`
|
|
JOIN `vn`.`accounting` `a` ON(`a`.`id` = `p`.`bankFk`)
|
|
)
|
|
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`
|