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: Selecting every other code.... why wont THIS work?

Re: Selecting every other code.... why wont THIS work?

From: Niall Litchfield <n-litchfield_at_audit-commission.gov.uk>
Date: Mon, 3 Feb 2003 11:57:13 -0000
Message-ID: <3e3e5919$0$245$ed9e5944@reading.news.pipex.net>


"elziko" <elziko_at_NOTSPAMMINGyahoo.co.uk> wrote in message news:3e3e43f6$0$12354$afc38c87_at_news.easynet.co.uk...
> and so on. So by my reckoning, in order to select only every OTHER row in
> this table I should be able to do:
>
> SELECT testtime FROM testdata WHERE MOD(rownum,2) = 1
>
> But it returns no records! I've obviously missed something here?!?

Rownum isn't a real column. You might get what you are after with

select testtime from
(select testime,rownum rn from testdata) where mod(rn,2)=1;

You should be aware that select .... from testdata doesn't return an ordered set of records, so the concept of every second record is pretty much meaningless without an order by in the inner select.

--
Niall Litchfield
Oracle DBA
Audit Commission UK
Received on Mon Feb 03 2003 - 05:57:13 CST

Original text of this message

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