Reputation: 534
After a CTE with several joins, sub-queries, etc. I have a table pulling appointments that occurred, their location, the participants, the dates, ...
One of the columns I have MAX(DATE)
to pull the most recent visit date.
How can I do a SELECT
clause to see the visit date that occurred right before the most recent one?
Would I place it in a subquery?
Upvotes: 0
Views: 60
Reputation: 387
Try this one
select *
from (
select *, row_number() over(order by [date]) as rownum
from myresult
) T where rownum = 2
Upvotes: 2