feat: refs #6822 poner esquemas en el with
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
be394cec28
commit
3f4aa60cd2
|
@ -75,27 +75,27 @@ BEGIN
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tBuy
|
CREATE OR REPLACE TEMPORARY TABLE tBuy
|
||||||
WITH tBuy AS (
|
WITH tBuy AS (
|
||||||
SELECT b.itemFk, SUM(b.quantity) totalQuantity
|
SELECT b.itemFk, SUM(b.quantity) totalQuantity
|
||||||
FROM buy b
|
FROM vn.buy b
|
||||||
WHERE b.entryFk = vOriginalEntry
|
WHERE b.entryFk = vOriginalEntry
|
||||||
GROUP BY b.itemFk
|
GROUP BY b.itemFk
|
||||||
),
|
),
|
||||||
itemShelvings AS (
|
itemShelvings AS (
|
||||||
SELECT ish.itemFk, SUM(visible) visible
|
SELECT ish.itemFk, SUM(visible) visible
|
||||||
FROM itemShelving ish
|
FROM vn.itemShelving ish
|
||||||
JOIN shelving sh ON sh.code = ish.shelvingFk
|
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
|
||||||
JOIN parking p ON p.id = sh.parkingFk
|
JOIN vn.parking p ON p.id = sh.parkingFk
|
||||||
JOIN sector s ON s.id = p.sectorFk
|
JOIN vn.sector s ON s.id = p.sectorFk
|
||||||
WHERE s.warehouseFk = vWarehouseFk
|
WHERE s.warehouseFk = vWarehouseFk
|
||||||
AND sh.parked = util.VN_CURDATE()
|
AND sh.parked = util.VN_CURDATE()
|
||||||
GROUP BY ish.itemFk
|
GROUP BY ish.itemFk
|
||||||
),
|
),
|
||||||
sales AS (
|
sales AS (
|
||||||
SELECT s.itemFk, SUM(s.quantity) sold
|
SELECT s.itemFk, SUM(s.quantity) sold
|
||||||
FROM ticket t
|
FROM vn.ticket t
|
||||||
JOIN sale s ON s.ticketFk = t.id
|
JOIN vn.sale s ON s.ticketFk = t.id
|
||||||
JOIN itemShelvingSale iss ON iss.saleFk = s.id
|
JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id
|
||||||
JOIN itemShelving is2 ON is2.id = iss.itemShelvingFk
|
JOIN vn.itemShelving is2 ON is2.id = iss.itemShelvingFk
|
||||||
JOIN shelving s2 ON s2.code = is2.shelvingFk
|
JOIN vn.shelving s2 ON s2.code = is2.shelvingFk
|
||||||
WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
|
WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
|
||||||
AND s2.parked = util.VN_CURDATE()
|
AND s2.parked = util.VN_CURDATE()
|
||||||
GROUP BY s.itemFk
|
GROUP BY s.itemFk
|
||||||
|
|
Loading…
Reference in New Issue