Hello all:
Attached is an extract of data using the following SQL Statement:
SELECT tbl_Mileage_Log.Vehicle_Brass_Tag, Max(tbl_Mileage_Log.Read_Date) AS MaxOfRead_Date, tbl_Mileage_Log.Mileage, tbl_Mileage_Log.Hours, tbl_Mileage_Log.Odometer, tbl_Mileage_Log.Prev_Odometer
FROM tbl_Mileage_Log
GROUP BY tbl_Mileage_Log.Vehicle_Brass_Tag, tbl_Mileage_Log.Mileage, tbl_Mileage_Log.Hours, tbl_Mileage_Log.Odometer, tbl_Mileage_Log.Prev_Odometer
HAVING (((Max(tbl_Mileage_Log.Read_Date)) Between [Enter Start Date] And [Enter End Date]))
ORDER BY tbl_Mileage_Log.Vehicle_Brass_Tag, Max(tbl_Mileage_Log.Read_Date) DESC;
Something is not quite right, outside of me, that the max date is not being returned, within brass tag group. Any and all help is greatly appreciated.
Bill K.
Trying to extract latest date
-
- StarLounger
- Posts: 71
- Joined: 27 Aug 2010, 09:13
Trying to extract latest date
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78481
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Trying to extract latest date
This is because you also group by Mileage, Hours, Odometer, and Prev_Odometer. You get the max for each unique combination of the fields that you group by.
If you want to group by Vehicle_Brass_Tag only, you must either remove the other group by fields from the query, or change Group By to one of the aggregate functions such as Sum, Max or Average for those fields.
If you want to group by Vehicle_Brass_Tag only, you must either remove the other group by fields from the query, or change Group By to one of the aggregate functions such as Sum, Max or Average for those fields.
Best wishes,
Hans
Hans
-
- StarLounger
- Posts: 71
- Joined: 27 Aug 2010, 09:13
Re: Trying to extract latest date
Thank you Hans. I'll narrow it down.