Subject: Most Recent Date
Posted By: Ludgero Post Date: 8/8/2006 6:05:21 PM
I have a database that has information on status of employee's. I'm trying to write a SQL statement that will select only information from the Most recent date. I can get this to work with a simple script, but when I attempt to add the rest of the information in, Trouble!

SELECT Max(qryOpen_Action.Rec_Date) AS aRec_Date, qryOpen_Action.StaffID
FROM qryOpen_Action
GROUP BY qryOpen_Action.StaffID;

This script only uses two fields currently, but I need quite a few more. other fields I want to integrate are, Action, Department, Position, ROP. I do NOT want all the fields grouped tho. I can get it to work by MAX'n the Rec_Date & having all the other fields grouped, but that is not how I need the data. I just want the most Recent Date for the different StaffID's & the other accompanying data! Is there a way to avoid grouping everything together?

Thanks MUCH!
Reply By: dparsons Reply Date: 8/29/2006 12:48:46 PM
This should work for you:

select q.StaffID, q.field, q.field from qryOpen_Action q where q.Rec_Date = (SELECT max(qry.Rec_Date) from qryOpen_Action qry)

hth

"The one language all programmers understand is profanity."

Go to topic 48962

Return to index page 191
Return to index page 190
Return to index page 189
Return to index page 188
Return to index page 187
Return to index page 186
Return to index page 185
Return to index page 184
Return to index page 183
Return to index page 182