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

21 lines
588 B
SQL

CREATE OR REPLACE DEFINER=`root`@`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`.`code` = `ish`.`shelvingFk`)
)
JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`)
)
GROUP BY `iss`.`saleFk`