Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> discarding first and last element from an ordered set of values
I need to discard the first and last element from an ordered set of
values returned by a query.
For example, I have the following query:
select
data
from
tab
order by
data
;
The result (6 rows) is:
260
260
266
270
273
274
But I need to discard the first and last element, so I need only 4 values:
260
266
270
273
I found out that I can easily discard the first element with the following query:
select
data
from
(
select data, row_number() over (order by data) rwnum from tab
rwnum>1
;
But how can I discard the last element, giving that I don't know in advance how many rows will be returned by the query?
Thank you. Kind regards,
-- Cris Carampa (spamto:cris119_at_operamail.com) potevo chiedere come si chiama il vostro cane il mio è un po' di tempo che si chiama LiberoReceived on Mon Feb 20 2006 - 08:14:33 CST