I have this query which is returning some redundant data. Can somebody please help me to correct this query. I have also attached the table relationship.
which is not exactly what I was want. the last column qtyArrived should show only its related qty but here as you can see it is repeating for each of the productID
what do you mean. i have printed my result,it is duplicating the data. for e.g. for all the productID it is repeating the same qtyArrived. my final result should return only 4 records.
Can you explain how you would derive those rows from the data you posted earlier? I am not seeing any rhyme or reason. Take that first row:
1 1 (null) 2013-12-10 12:35:03 true 5 8 (null) 223444 1 8
I assume it comes from the following rows:
1 1 (null) 2013-12-10 12:35:03 true 5 8 (null) 223444 1 2
1 1 (null) 2013-12-10 12:35:03 true 5 8 (null) 223444 1 8
Is it the"last" one that you are looking for? If so, can you define the "last" one?
Anthony Perkins
For the second row:
1 1 (null) 2013-12-10 12:35:03 true 1 3 (null) 223444 1 2
I am assuming it is coming from:
1 1 (null) 2013-12-10 12:35:03 true 1 3 (null) 223444 1 2
1 1 (null) 2013-12-10 12:35:03 true 1 3 (null) 223444 1 8
But here you appear to have picked the "first" one.
Perhaps it does not matter which one is returned.
Zolf
ASKER
thanks for your comments.
see the invoice numbers in the result. the idea is to get the products which the supplier has sent to the client. the products could have come in one batch or in small batches. the productid 1 has come in 2 batches(the orderQty by the client was 3 but it qtyArrived in 2 batches of 1 and 2). see the attached file. table-relationship.png
which is not exactly what I was want. the last column qtyArrived should show only its related qty but here as you can see it is repeating for each of the productID
sectionID supplierID supplierOrderNo supplierOrderCreated supplierOrderConfirmStatus
1 1 (null) 2013-12-10 12:35:03 true 5 8 (null) 223444 1 2
1 1 (null) 2013-12-10 12:35:03 true 1 3 (null) 223444 1 2
1 1 (null) 2013-12-10 12:35:03 true 6 4 (null) 223444 1 2
1 1 (null) 2013-12-10 12:35:03 true 5 8 (null) 223444 1 8
1 1 (null) 2013-12-10 12:35:03 true 1 3 (null) 223444 1 8
1 1 (null) 2013-12-10 12:35:03 true 6 4 (null) 223444 1 8
1 1 (null) 2013-12-10 12:35:03 true 5 8 (null) 565333 2 1
1 1 (null) 2013-12-10 12:35:03 true 1 3 (null) 565333 2 1
1 1 (null) 2013-12-10 12:35:03 true 6 4 (null) 565333 2 1
1 1 (null) 2013-12-10 12:35:03 true 5 8 (null) 565333 2 4
1 1 (null) 2013-12-10 12:35:03 true 1 3 (null) 565333 2 4
1 1 (null) 2013-12-10 12:35:03 true 6 4 (null) 565333 2 4