I am trying to create a query that will return the 2 most recent dates. I currently have my query returning the Max & Min but instead of the Min date I want it to return the next most recent date. Here is what I have so far
SELECT qryCodeRestrictions.LastName, qryCodeRestrictions.FirstName, qryCodeRestrictions.DateofBirth, qryCodeRestrictions.ProcedureCode, Max(qryCodeRestrictions.DateofService) AS MaxOfDateofService, Min(qryCodeRestrictions.DateofService) AS MinOfDateofService, DateDiff("m",[MinOfDateOfService],[MaxOfDateOfService]) AS DaysBetweenServices, qryCodeRestrictions.Provider
FROM qryCodeRestrictions
GROUP BY qryCodeRestrictions.LastName, qryCodeRestrictions.FirstName, qryCodeRestrictions.DateofBirth, qryCodeRestrictions.ProcedureCode, qryCodeRestrictions.Provider