I am trying the following query in and oleDbCommand:
SELECT PartLocations.L ocationName, Sum(PartsJourna l.Quantity) AS
SumOfQuantity, PartsJournal.Pa rtsLotNumber
FROM PartLocations INNER JOIN PartsJournal ON PartLocations.L ocationID
= PartsJournal.Lo cationID
GROUP BY PartLocations.L ocationName, PartsJournal.Pa rtsLotNumber,
PartsJournal.Pa rtNumber, PartsJournal.Lo cationID
HAVING (((Sum(PartsJou rnal.Quantity)) >0) AND
((PartsJournal. PartsLotNumber) Is Not Null) AND
((Min(PartsJour nal.Date))>'5/1/2001') AND
((PartsJournal. PartNumber)='03 0020') AND
((PartsJournal. LocationID)<>1) )
ORDER BY PartsJournal.Pa rtNumber, MIN(PartsJourna l.Date);
It generates an excpetion. If I take out the MIN(PartsJourna l.Date) in
the ORDER BY clause it works fine. But when I check the query as is
in SQL Query Analyzer it runs fine with the MIN(PartsJourna l.Date).
Why the difference?
SELECT PartLocations.L ocationName, Sum(PartsJourna l.Quantity) AS
SumOfQuantity, PartsJournal.Pa rtsLotNumber
FROM PartLocations INNER JOIN PartsJournal ON PartLocations.L ocationID
= PartsJournal.Lo cationID
GROUP BY PartLocations.L ocationName, PartsJournal.Pa rtsLotNumber,
PartsJournal.Pa rtNumber, PartsJournal.Lo cationID
HAVING (((Sum(PartsJou rnal.Quantity)) >0) AND
((PartsJournal. PartsLotNumber) Is Not Null) AND
((Min(PartsJour nal.Date))>'5/1/2001') AND
((PartsJournal. PartNumber)='03 0020') AND
((PartsJournal. LocationID)<>1) )
ORDER BY PartsJournal.Pa rtNumber, MIN(PartsJourna l.Date);
It generates an excpetion. If I take out the MIN(PartsJourna l.Date) in
the ORDER BY clause it works fine. But when I check the query as is
in SQL Query Analyzer it runs fine with the MIN(PartsJourna l.Date).
Why the difference?
Comment