Duplicate records

G

Guest

Hi. I have a query that joins two other queries. I want to create a report
using the final query. Query 1 lists sales orders. Query 2 lists production
schedules. When I join the two queries (query 3) by item and warehouse, I get
duplicate records for both sales orders and production schedules. I can
handle this by hiding duplicates in the report. But sometimes there are
multiple production schedules and multiple sales orders. In this case, I
can't seem to get around the duplicate records.
Example:
Item 12345 SO#2345 Qty 300 PO#3456 Qty 500
SO#3456 Qty 400
SO#4567 Qty 350
SO#2345 Qty 300 PO#5678 Qty 800
SO#3456 Qty 400
etc...
Any suggestions how to eliminate this duplication problem?

Here is the query in SQL format:
SELECT DISTINCTROW [qry_Tender Exceptions].ITMID, [qry_Tender
Exceptions].ITMDESC, [qry_Tender Exceptions].XSRESC, [qry_Tender
Exceptions].DISTCTR, [qry_Tender Exceptions].CALCULATED_TENDER_DATE_M1,
[qry_Tender Exceptions].SCHEDULED_DELIVERY_DATE_M1, Sum([qry_Tender
Exceptions].QTYORD) AS SumOfQTYORD, [qry_Tender Exceptions].OHQTY,
[qry_Production Schedules].RDSCHD, [qry_Production Schedules].RDRSDT,
[qry_Production Schedules].RDRDDT, [qry_Production Schedules].RDSRRQ
FROM [qry_Tender Exceptions] LEFT JOIN [qry_Production Schedules] ON
([qry_Tender Exceptions].XSRESC = [qry_Production Schedules].RDPMNM) AND
([qry_Tender Exceptions].DISTCTR = [qry_Production Schedules].RDWHSE)
GROUP BY [qry_Tender Exceptions].ITMID, [qry_Tender Exceptions].ITMDESC,
[qry_Tender Exceptions].XSRESC, [qry_Tender Exceptions].DISTCTR, [qry_Tender
Exceptions].CALCULATED_TENDER_DATE_M1, [qry_Tender
Exceptions].SCHEDULED_DELIVERY_DATE_M1, [qry_Tender Exceptions].OHQTY,
[qry_Production Schedules].RDSCHD, [qry_Production Schedules].RDRSDT,
[qry_Production Schedules].RDRDDT, [qry_Production Schedules].RDSRRQ;


Thanks so much!
 
G

Guest

Try this ---
FROM [qry_Production Schedules] LEFT JOIN ON [qry_Tender Exceptions]
(qry_Production Schedules].ITMID=[qry_Tender Exceptions].ITMID [) AND
([qry_Production Schedules].RDWHSE=[qry_Tender Exceptions].DISTCTR)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top