delphi6BDE
Programmer
Hello,
Is there a way to change this query to also include the maximum ordered regardless of account for the selected date? I need to be able to reference the maximum value for the selected date in order to see if the work can be done for the day. For example, if a client ordered 10,000 pieces, and another ordered 50,000 pieces, but the work must be done together, the work cannot start if the second customer's product is not there. (hope that makes sense) I will be using the results in a delphi app I'm writing, and the max value ordered for the day will be used to populate a progress bar within a grid to show the user how much work can be performed before the missing product arrives (if not 100%)
My query right now:
SELECT
tblAccounts.strName,
tblSpecs.strPhrase,
tblSpecs.strCode,
tblSpecs.strVer,
Sum(tblHistory.lngQty) AS Ordered,
tblEntity.strEntity,
tblSpecs.dtmDist
FROM
tblAccounts
INNER JOIN
((tblSpecs
INNER JOIN tblEntity ON
tblSpecs.entityID = tblEntity.entityID)
INNER JOIN tblHistory ON
(tblSpecs.specsID = tblHistory.specsID) AND
(tblEntity.entityID = tblHistory.entityID)) ON
tblAccounts.strAccount = tblSpecs.strAccount
WHERE
(((tblSpecs.ysnCancelled)=0) AND
((tblSpecs.ysnReceived)=0))
GROUP BY
tblAccounts.strName,
tblSpecs.strPhrase,
tblSpecs.strCode,
tblSpecs.strVer,
tblEntity.strEntity,
tblSpecs.dtmDist
HAVING
(((tblEntity.strEntity)="entity") AND
((tblSpecs.dtmDist)=#12/28/2011#));
Is there a way to change this query to also include the maximum ordered regardless of account for the selected date? I need to be able to reference the maximum value for the selected date in order to see if the work can be done for the day. For example, if a client ordered 10,000 pieces, and another ordered 50,000 pieces, but the work must be done together, the work cannot start if the second customer's product is not there. (hope that makes sense) I will be using the results in a delphi app I'm writing, and the max value ordered for the day will be used to populate a progress bar within a grid to show the user how much work can be performed before the missing product arrives (if not 100%)
My query right now:
SELECT
tblAccounts.strName,
tblSpecs.strPhrase,
tblSpecs.strCode,
tblSpecs.strVer,
Sum(tblHistory.lngQty) AS Ordered,
tblEntity.strEntity,
tblSpecs.dtmDist
FROM
tblAccounts
INNER JOIN
((tblSpecs
INNER JOIN tblEntity ON
tblSpecs.entityID = tblEntity.entityID)
INNER JOIN tblHistory ON
(tblSpecs.specsID = tblHistory.specsID) AND
(tblEntity.entityID = tblHistory.entityID)) ON
tblAccounts.strAccount = tblSpecs.strAccount
WHERE
(((tblSpecs.ysnCancelled)=0) AND
((tblSpecs.ysnReceived)=0))
GROUP BY
tblAccounts.strName,
tblSpecs.strPhrase,
tblSpecs.strCode,
tblSpecs.strVer,
tblEntity.strEntity,
tblSpecs.dtmDist
HAVING
(((tblEntity.strEntity)="entity") AND
((tblSpecs.dtmDist)=#12/28/2011#));