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

36 lines
1.0 KiB
MySQL
Raw Permalink Normal View History

2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost`
2024-01-25 16:33:54 +00:00
SQL SECURITY DEFINER
VIEW `vn`.`itemShelvingStock`
AS SELECT `ish`.`itemFk` AS `itemFk`,
sum(`ish`.`visible`) AS `visible`,
min(`ish`.`packing`) AS `packing`,
min(`ish`.`grouping`) AS `grouping`,
`s`.`description` AS `sector`,
sum(`ish`.`visible`) AS `visibleOriginal`,
0 AS `removed`,
`p`.`sectorFk` AS `sectorFk`,
`s`.`warehouseFk` AS `warehouseFk`,
`ish`.`shelvingFk` AS `shelvingFk`,
`p`.`code` AS `parkingCode`,
`sh`.`parkingFk` AS `parkingFk`,
`ish`.`id` AS `itemShelvingFk`,
`ish`.`created` AS `created`,
`st`.`code` = 'previousPrepared' AS `isPreviousPrepared`
2024-01-25 16:33:54 +00:00
FROM (
(
(
(
`vn`.`itemShelving` `ish`
2024-11-13 08:56:38 +00:00
LEFT JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`)
2024-01-25 16:33:54 +00:00
)
LEFT JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`)
)
LEFT JOIN `vn`.`sector` `s` ON(`s`.`id` = `p`.`sectorFk`)
)
LEFT JOIN `vn`.`sectorType` `st` ON(`st`.`id` = `s`.`typeFk`)
)
WHERE `ish`.`visible` <> 0
AND `p`.`sectorFk` <> 0
GROUP BY `ish`.`itemFk`,
`p`.`sectorFk`