Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quadruple record problem in query

Status
Not open for further replies.

sparkyout

Technical User
Jun 5, 2003
36
US
QryFieldTotals below gives all records that have [SOType]=kdb and [Status]=Is Null.

QryOrderForecasts below gives all records with [OrderComplete]=0 and includes the [SchedShipDate] and [SchedShipQty]

The problem is that a record, which is an order, consist of [FSONO] and [SeqNo]. It can have one or multiple [SEQNO]--(Example: 123456-01, 123456-02, 123456-03......)
Separately these queries work beautifully. Combined the records are quadrupled and different [SchedShipDate] are assigned to all records.

Does anyone have any solutions/suggestions as to how I can combine the queries without quadruple records?????????????????????????


QryFieldTotals
--------------
SELECT somnew.SOTYPE, sotrnew.STATUS, somnew.FCUSTNO, sotrnew.FSONO, sotrnew.SEQNO, Sum(sotrnew.FAMOUNT) AS TotalOrderAmount, Sum(sotrnew.FORDQTY) AS TotalQtyOrdered, sotrnew.FPRICE, somnew.FCOMPANY, somnew.FPONO, Sum(sotrnew.FSHIPQTY) AS TotalDiesShipped, sotrnew.FITEMNO, sotrnew.FDUEDATE, somnew.FORDDATE
FROM somnew INNER JOIN sotrnew ON somnew.FSONO = sotrnew.FSONO
GROUP BY somnew.SOTYPE, sotrnew.STATUS, somnew.FCUSTNO, sotrnew.FSONO, sotrnew.SEQNO, sotrnew.FPRICE, somnew.FCOMPANY, somnew.FPONO, sotrnew.FITEMNO, sotrnew.FDUEDATE, somnew.FORDDATE
HAVING (((somnew.SOTYPE)="kdb") AND ((sotrnew.STATUS) Is Null))
ORDER BY somnew.FCUSTNO, sotrnew.FSONO, sotrnew.SEQNO;

QryOrderForecasts
------------------
SELECT tblOrderForecasts.OrderComplete, tblOrderForecasts.FSONO, tblOrderForecasts.SeqNO, tblOrderForecasts.SchedShipDate, tblOrderForecasts.SchedShipQty
FROM tblOrderForecasts
WHERE (((tblOrderForecasts.OrderComplete)=0))
ORDER BY tblOrderForecasts.SchedShipDate;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top