kazzi
kazzi

Reputation: 534

SELECT second before most recent Date

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

Answers (1)

Artashes  Khachatryan
Artashes Khachatryan

Reputation: 387

Try this one

select *
from (
select *, row_number() over(order by [date]) as rownum
from myresult
) T where rownum = 2

Upvotes: 2

Related Questions