cancel
Showing results for 
Search instead for 
Did you mean: 

Need Help; Query repeating Rows.

former_member224264
Participant
0 Kudos
509

Dear Experts,

We have devised this query by using query generator and when executed, the item nos are repeating even though we have used the "Distinct" function. please help us.

SELECT DISTINCT T0.DocEntry,T0.[DocNum], T0.[PostDate], T0.DueDate, T0.[ItemCode], T0.[PlannedQty], T1.[ItemCode], T1.[PlannedQty], T3.OnHand, T0.Status, T1.[IssuedQty], T0.Comments FROM OWOR T0 INNER JOIN WOR1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode inner JOIN OITW T3 ON T1.[ItemCode] = T3.[ItemCode] WHERE T1.[IssuedQty]<=0 and (T0.[Status] ='P' or T0.[Status] ='R') ORDER BY T0.[PostDate]

Can anyone please help us?

Regards.

View Entire Topic
0 Kudos

Hello Mekhala P,

Problem with OITW, it contains items with all warehouse onhand quantity.

You have to join warehouse code of T1 with WhsCode of OITW T3 like

OITW T3 ON T1.[ItemCode] = T3.[ItemCode] and T1.warehouse=T3.WhsCode

Regards,

Zuber Kazi

former_member224264
Participant
0 Kudos

Greetings Zuber Kazi,

Did try with your suggestion and found that the items are repeating three times in consecutive rows.

Regards.