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?
I tried it and the command return 1 record. It probably has something to
do when rownum is actually computed as opposed to when the where clause
is applied.
You can do something like:
select x, y from
(select x, mod(rownum, 2) y from test)
where y = 1
;
which seems to work, but working with rownum can be a little tricky. Just be sure you really do want what you ask for, because you will get what you ask for.
"elziko" <elziko_at_NOTSPAMMINGyahoo.co.uk> wrote in message news:<3e3e43f6$0$12354$afc38c87_at_news.easynet.co.uk>...
> If I do the following:
>
> SELECT testtime, MOD(rownum,2) FROM testdata
>
> I get the following output:
>
> 0.0 1
> 0.1 0
> 0.2 1
> 0.3 0
> 0.4 1
>
> 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?!?
>
> Cheers,
>
> elziko
Received on Mon Feb 03 2003 - 09:32:57 CST
![]() |
![]() |