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

21 lines
584 B
SQL

CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`itemShelvingSaleSum`
AS SELECT `iss`.`id` AS `id`,
`iss`.`itemShelvingFk` AS `itemShelvingFk`,
`iss`.`saleFk` AS `saleFk`,
sum(`iss`.`quantity`) AS `quantity`,
`iss`.`created` AS `created`,
`p`.`sectorFk` AS `sectorFk`
FROM (
(
(
`vn`.`itemShelvingSale` `iss`
JOIN `vn`.`itemShelving` `ish` ON(`ish`.`id` = `iss`.`itemShelvingFk`)
)
JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`)
)
JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`)
)
GROUP BY `iss`.`saleFk`