Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Getting first and last rank
Using Oracle 9.2.0.4
I have a requirement to get the first and last rows when the data is ordered by time in a table. The only way I have been able to do is to use rank() twice (first two sort ascending and then sort descending), obtain two result sets, union them and then filter on rank = 1. This works but I don't like the idea of having to sort twice. Can I do this in a single query without having to sort it twice and union it.
Thanks.
Puneet
Received on Wed Jun 06 2007 - 12:23:55 CDT