I have a query as follows:
The results give two independent MaxOf answers so the MaxOf the cropping year and the Max of the Crop order for each field code.
What I really want is a query that calculates the MaxOf cropping year and then calculates the Max of Crop order but only for the already calculated MaxOfCropping Year.
So for example if Field A had
cropping year 2004 and for that year had crop order 8 & 9
cropping year 2005 and for that year crop order 5 & 6
Cropping year 2006 and for that year crop order 1 & 2
my query returns MaxOfCroppingYear 2006 MaxOfCropOrder 9
but what I want it to return is MaxOfCroppingYear 2006 MaxOfCropOrder 2
Hope this makes sense, brain is shredded. Thanks in advance for any help
Code:
SELECT tblFieldDetails.FarmAccountNumber, tblCropping.FieldCode, Max(tblCropping.CroppingYear) AS [MaxOfCropping Year], Max(tblCropping.CropOrder) AS [MaxOfCrop Order]
FROM (tblFieldDetails LEFT JOIN tblCropping ON tblFieldDetails.FieldCode = tblCropping.FieldCode) INNER JOIN tblSelect ON tblFieldDetails.FarmAccountNumber = tblSelect.FarmAccountNumber
GROUP BY tblFieldDetails.FarmAccountNumber, tblCropping.FieldCode;
The results give two independent MaxOf answers so the MaxOf the cropping year and the Max of the Crop order for each field code.
What I really want is a query that calculates the MaxOf cropping year and then calculates the Max of Crop order but only for the already calculated MaxOfCropping Year.
So for example if Field A had
cropping year 2004 and for that year had crop order 8 & 9
cropping year 2005 and for that year crop order 5 & 6
Cropping year 2006 and for that year crop order 1 & 2
my query returns MaxOfCroppingYear 2006 MaxOfCropOrder 9
but what I want it to return is MaxOfCroppingYear 2006 MaxOfCropOrder 2
Hope this makes sense, brain is shredded. Thanks in advance for any help