on 2020 Apr 14 2:04 PM
I need a query for inventory with batch number, current quantity on hand and original receipt date. I can't find a table with batch numbers.
Hi kathy.walker2, please check these tables:
SELECT B2.*,
B3."Quantity"
FROM (SELECT B0."SysNumber",
B0."ItemCode",
B0."BatchNum",
B0."WhsCode",
B1."BaseType" AS "BaseType",
MIN(B1."DocDate") AS "InDate"
FROM "OIBT" B0
INNER JOIN "IBT1" B1
ON B0."ItemCode" = B1."ItemCode"
AND B0."BatchNum" = B1."BatchNum"
AND B0."WhsCode" = B1."WhsCode"
WHERE B1."BaseType" IN( 18, 67 )
AND B1."Direction" = 0
GROUP BY B0."SysNumber",
B0."ItemCode",
B0."BatchNum",
B0."WhsCode",
B1."BaseType",
B1."DocDate"
ORDER BY B1."DocDate") B2
LEFT JOIN (SELECT B0."SysNumber",
B0."ItemCode",
B0."BatchNum",
B0."WhsCode",
SUM(CASE WHEN B1."Direction" = 0 THEN B1."Quantity" ELSE( -1 ) * B1."Quantity" END) AS "Quantity"
FROM "OIBT" B0
INNER JOIN "IBT1" B1
ON B0."ItemCode" = B1."ItemCode"
AND B0."BatchNum" = B1."BatchNum"
AND B0."WhsCode" = B1."WhsCode"
GROUP BY B0."SysNumber",
B0."ItemCode",
B0."BatchNum",
B0."WhsCode") B3
ON B2."SysNumber" = B3."SysNumber"
AND B2."ItemCode" = B3."ItemCode"
AND B2."BatchNum" = B3."BatchNum"
AND B2."WhsCode" = B3."WhsCode"
ORDER BY B2."InDate"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
can you describe your needs more clearly. like what parameters do you need then what information do you want to appear?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
113 | |
8 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.