I have a report where I need to pull the most recent comment on a claim and also the second most recent comment on a claim. The only solution I have found online for this is as follows:
SQL
1 2 3 4 5 | SELECTMAX(CommentID)FROMCommentTableWHERECommentID<(SELECTMAX(CommentID)FROMCommentTable) |
The issue here is that without that snippet, the report runs in one second. With it in there, it hit 45 minutes before the server resources balked at me and it crashed...
Is there an alternative/better way to pull the second highest value?