Hi ,
The bellow query working as expected , until include one more table in join .
Working query :
SELECT A.InventoryID,IV.CategoryID,Barcode,IV.Description,DateAdjusted AS RefDate,'Inventory Adjustment' AS RefType,CONCAT('IN ',trim(A.Notes)) AS RefNo,
AdjustQuantity As StockInQty, 0.00 AS StockOutQty, 0 As StockCheck
FROM da1.InventoryAdjust A
Inner Join da1.Inventory IV On A.InventoryID=IV.InventoryID
WHERE AdjustQuantity>0
and (Date(DateAdjusted) between '2025-03-07' and '2025-03-07')
Order By A.InventoryID ;
***************************************************************************
Sample Record :
4, 12, 'A02 ', 'The OG', '2025-03-07 10:20:57', 'Inventory Adjustment', 'IN Adj In', 10, 0.00, 0
4, 12, 'A02 ', 'The OG', '2025-03-07 13:16:39', 'Inventory Adjustment', 'IN Adj In', 5, 0.00, 0
5, 12, 'A03 ', 'Popeye`s Bowl', '2025-03-07 10:22:42', 'Inventory Adjustment', 'IN Adj In', 10, 0.00, 0
26, 6, 'C01', '01. KOPI O', '2025-03-07 10:19:45', 'Inventory Adjustment', 'IN Adj In', 5, 0.00, 0
after i include New table in inner join : inventorycostaveragedetail
SELECT A.InventoryID,IV.CategoryID,Barcode,IV.Description,DateAdjusted AS RefDate,'Inventory Adjustment' AS RefType,CONCAT('IN ',trim(A.Notes)) AS RefNo,
AdjustQuantity As StockInQty, 0.00 AS StockOutQty, 0 As StockCheck
FROM da1.InventoryAdjust A
Inner Join da1.Inventory IV On A.InventoryID=IV.InventoryID
join da1.inventorycostaveragedetail as ic on ic.Inventoryid=A.Inventoryid
WHERE AdjustQuantity>0
and (Date(DateAdjusted) between '2025-03-07' and '2025-03-07')
Order By A.InventoryID ;
Result :
4, 12, 'A02 ', 'The OG', '2025-03-07 13:16:39', 'Inventory Adjustment', 'IN Adj In', 5, 0.00, 0
4, 12, 'A02 ', 'The OG', '2025-03-07 10:20:57', 'Inventory Adjustment', 'IN Adj In', 10, 0.00, 0
4, 12, 'A02 ', 'The OG', '2025-03-07 13:16:39', 'Inventory Adjustment', 'IN Adj In', 5, 0.00, 0
4, 12, 'A02 ', 'The OG', '2025-03-07 10:20:57', 'Inventory Adjustment', 'IN Adj In', 10, 0.00, 0
4, 12, 'A02 ', 'The OG', '2025-03-07 13:16:39', 'Inventory Adjustment', 'IN Adj In', 5, 0.00, 0
4, 12, 'A02 ', 'The OG', '2025-03-07 10:20:57', 'Inventory Adjustment', 'IN Adj In', 10, 0.00, 0
5, 12, 'A03 ', 'Popeye`s Bowl', '2025-03-07 10:22:42', 'Inventory Adjustment', 'IN Adj In', 10, 0.00, 0
5, 12, 'A03 ', 'Popeye`s Bowl', '2025-03-07 10:22:42', 'Inventory Adjustment', 'IN Adj In', 10, 0.00, 0
26, 6, 'C01', '01. KOPI O', '2025-03-07 10:19:45', 'Inventory Adjustment', 'IN Adj In', 5, 0.00, 0
26, 6, 'C01', '01. KOPI O', '2025-03-07 10:19:45', 'Inventory Adjustment', 'IN Adj In', 5, 0.00, 0
26, 6, 'C01', '01. KOPI O', '2025-03-07 10:19:45', 'Inventory Adjustment', 'IN Adj In', 5, 0.00, 0
26, 6, 'C01', '01. KOPI O', '2025-03-07 10:19:45', 'Inventory Adjustment', 'IN Adj In', 5, 0.00, 0
26, 6, 'C01', '01. KOPI O', '2025-03-07 10:19:45', 'Inventory Adjustment', 'IN Adj In', 5, 0.00, 0
26, 6, 'C01', '01. KOPI O', '2025-03-07 10:19:45', 'Inventory Adjustment', 'IN Adj In', 5, 0.00, 0
The Problem is data is keep repeating , the resutl should be 4 rows instead of 14 rows . Cna any one help me to change this quey.
Thanks in advance
Karthik.K