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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Reduce data returned by a query

Re: Reduce data returned by a query

From: Andy <andy.spaven_at_eps-hq.co.uk>
Date: Fri, 24 Jan 2003 10:55:30 -0000
Message-ID: <WT8Y9.3684$9R.12349378@newsr2.u-net.net>


Whoops - got that wrong - always use the second form regardless of ORDER BY i.e.

SELECT * FROM (
    SELECT mycolumn, ..., rownum row_number FROM mytable )
WHERE mod(row_number,2) = 1

Andy

"Andy" <andy.spaven_at_eps-hq.co.uk> wrote in message news:5B8Y9.3682$9R.12348479_at_newsr2.u-net.net...
> SELECT mycolumn FROM mytable;
> WHERE mod(rownum,2) = 1
>
> or use =0 to get second, fourth, sixth etc.
>
>
> If you want to do this for a select that uses an order by you'll need to
> change the format to
>
> SELECT * FROM (
> SELECT mycolumn FROM mytable ORDER BY myothercolumn
> )
> WHERE mod(rownum,2) = 1
>
> "elziko" <elziko_at_NOTSPAMMINGyahoo.co.uk> wrote in message
> news:3e3113d2$0$2576$afc38c87_at_news.easynet.co.uk...
> > If I have a query such as :
> >
> > SELECT mycolumn FROM mytable;
> >
> > ...which returns eight rows like so:
> >
> > "One"
> > "Two"
> > "Three"
> > "Four"
> > "Five"
> > "Six"
> > "Seven"
> > "Eight"
> >
> > Is it possible to return only every OTHER row? So that only the odd
> numbered
> > rows are returned like so:
> >
> > "One"
> > "Three"
> > "Five"
> > "Seven"
> >
> > I know I can just get rid of my data after the query but then I'm
wasting
> > the DB access time getting data I dont want.
> >
> > Many thanks,
> >
> > elziko
> >
> >
>
>
Received on Fri Jan 24 2003 - 04:55:30 CST

Original text of this message

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