Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> discarding first and last element from an ordered set of values

discarding first and last element from an ordered set of values

From: Cris Carampa <cris119_at_operamail.com>
Date: Mon, 20 Feb 2006 15:14:33 +0100
Message-ID: <43f9cef3$0$29099$5fc30a8@news.tiscali.it>


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

   )
where

   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 Libero
Received on Mon Feb 20 2006 - 08:14:33 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US