28 lines
771 B
MySQL
28 lines
771 B
MySQL
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||
|
SQL SECURITY DEFINER
|
||
|
VIEW `vn`.`itemShelvingStock` AS
|
||
|
SELECT ish.itemFk,
|
||
|
SUM(ish.visible) visible,
|
||
|
MIN(ish.packing) packing,
|
||
|
MIN(ish.`grouping`) `grouping`,
|
||
|
s.description sector,
|
||
|
SUM(ish.visible) visibleOriginal,
|
||
|
0 removed,
|
||
|
p.sectorFk,
|
||
|
s.warehouseFk,
|
||
|
ish.shelvingFk,
|
||
|
p.code,
|
||
|
sh.parkingFk,
|
||
|
ish.id itemShelvingFk,
|
||
|
ish.created,
|
||
|
st.description = 'previousPrepared' isPreviousPrepared
|
||
|
FROM itemShelving ish
|
||
|
LEFT JOIN shelving sh ON sh.code = ish.shelvingFk
|
||
|
LEFT JOIN parking p ON p.id = sh.parkingFk
|
||
|
LEFT JOIN sector s ON s.id = p.sectorFk
|
||
|
LEFT JOIN sectorType st ON st.id = s.typeFk
|
||
|
WHERE ish.visible <> 0
|
||
|
AND p.sectorFk <> 0
|
||
|
GROUP BY ish.itemFk,
|
||
|
p.sectorFk
|