Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Selecting every other code.... why wont THIS work?
"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 UKReceived on Mon Feb 03 2003 - 05:57:13 CST