Link to home
Start Free TrialLog in
Avatar of maroulator
maroulator

asked on

Most recent dates

To whom it may concern,

The attached file represents the output that I get after running a query in MS Access. From this output, I need to pick the records with the most recent and second most recent dates FOR EACH individual.

Does anyone have any ideas?

-Maroulator
Example.xlsx
Avatar of vadoodetm
vadoodetm
Flag of United States of America image

Do you want to do this in excel?  Or you want to modify your Access query to give desired output?
Avatar of maroulator
maroulator

ASKER

I want to modify my Access query. I was thinking of creating a make-table query to produce the output that I have in the attached spreadsheet and then run another query (this is where you come in) to pick the most recent and second most recent dates from the table created out of the make-table query.

I am open to any and all ideas; if you can produce a query that gives me the output in the attached spreadsheet AND picks the most recent and second most recent dates, then so much the better.

Let me know if you have any more questions.

-Maroulator
Avatar of als315
If your query is named qry, you can use this query:
SELECT qry.Name, qry.Salary, qry.Title, qry.Date
FROM qry
WHERE (qry.Date In (SELECT Top 2 [Date] From qry as q Where q.Name = qry.Name Order by q.Date))
ORDER BY qry.Name, qry.Date DESC;

Open in new window

Try not to use reserved words (Date, Name) as field name. In this case you should use square brackets around this field
And how can I take the percentage difference between the two records within the same query?
ASKER CERTIFIED SOLUTION
Avatar of als315
als315
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial