Home » SQL & PL/SQL » SQL & PL/SQL » Query not working (Oracle 9i)
Query not working [message #297210] Wed, 30 January 2008 12:07 Go to next message
renjithtkm
Messages: 5
Registered: January 2008
Location: TVM
Junior Member
Why is this query not working. I intend to get the alternate rows.

select * from <table> where mod(rownum,2)=0

why is above query not working as i expected to be?.

I am able to get alternate rows by the following query

select * from <table> where (rowid,0) in (select rowid,mod(rownum,2)from <table>).

Please explain why the first query is not working?.
Re: Query not working [message #297212 is a reply to message #297210] Wed, 30 January 2008 12:19 Go to previous messageGo to next message
S.Rajaram
Messages: 1027
Registered: October 2006
Location: United Kingdom
Senior Member
Welcome to the forum. This being your first post take some time read the forums guidelines. Also read the following link. It will clarify your doubts.

http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/pseudocolumns009.htm#i1006297

Regards

Raj
Re: Query not working [message #297216 is a reply to message #297210] Wed, 30 January 2008 12:51 Go to previous messageGo to next message
Michel Cadot
Messages: 64140
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Also As you are a newbie post in newbue forum not expert one.
Newbie forum does not mean it is answered by newbies but it is asked by newbies.
Expert forum means it is expert question from expert posters.
Both forum are answered by the same people.

Regards
Michel
Re: Query not working [message #297235 is a reply to message #297212] Wed, 30 January 2008 14:35 Go to previous messageGo to next message
renjithtkm
Messages: 5
Registered: January 2008
Location: TVM
Junior Member
Thanks Rajaram..But i am still having the doubt...Why is the query select * from <table> where mod(rownum,2) = 0 wont return the alternate rows?..
Re: Query not working [message #297237 is a reply to message #297235] Wed, 30 January 2008 14:58 Go to previous messageGo to next message
S.Rajaram
Messages: 1027
Registered: October 2006
Location: United Kingdom
Senior Member
SQL> select rownum, table_name from cat;
SQL> select rownum, table_name from cat where rownum < 3;
SQL> select rownum, table_name from cat where rownum > 1;


Execute the above query and figure it out yourself why your query is not working. If you still cannot understand read the manual again and again, you will definitely understand why your query is not working.

Happy learning

Regards

Raj
Re: Query not working [message #297238 is a reply to message #297210] Wed, 30 January 2008 15:04 Go to previous messageGo to next message
flyboy
Messages: 1832
Registered: November 2006
Senior Member
Read more precise explanation, given in Rownum thread on AskTom.
Re: Query not working [message #297443 is a reply to message #297210] Thu, 31 January 2008 11:12 Go to previous message
renjithtkm
Messages: 5
Registered: January 2008
Location: TVM
Junior Member
Thanks For referring to Tom.I got the answer.
Previous Topic: extension for view
Next Topic: Privilege issue while trying to delete record
Goto Forum:
  


Current Time: Fri Dec 09 09:20:58 CST 2016

Total time taken to generate the page: 0.10834 seconds