Home » SQL & PL/SQL » SQL & PL/SQL » SQL (Rows between 20 and 30 OR given range)
icon5.gif  SQL [message #347722] Sat, 13 September 2008 03:35 Go to next message
prachi.mgorwadkar
Messages: 75
Registered: May 2007
Location: Pune
Member
Hello Al,

I have one query :

How to select rows between 20 and 30.

I tried following,

select * from table
where rownum <= 30
MINUS
select * from table
where rownum <= 10

Buth this is not the solution.

Do anybody has a better solution?

Thanks and Regards,
-Prachi

Re: SQL [message #347724 is a reply to message #347722] Sat, 13 September 2008 03:57 Go to previous messageGo to next message
Michel Cadot
Messages: 64122
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Unless you specify an order the sentence "rows between 20 and 30" is undetermistic, so you can just take the 10 first rows that comes.

You can also search as this question has been asked many and many times.

Regards
Michel
icon5.gif  Re: SQL [message #347728 is a reply to message #347724] Sat, 13 September 2008 04:40 Go to previous messageGo to next message
prachi.mgorwadkar
Messages: 75
Registered: May 2007
Location: Pune
Member
Thanks for the reply, Sir.

But, first I tried searching this question , and I did not get it.

I have searched it using the keywors as : 'rows between 20 and 30' in PL/SQL Topics

So, I put it this column.

Thanks
-Prachi
Re: SQL [message #347729 is a reply to message #347728] Sat, 13 September 2008 05:00 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Adding 20 and 30 to your search-criteria might reduce your chances for succes...
Re: SQL [message #347743 is a reply to message #347728] Sat, 13 September 2008 09:27 Go to previous messageGo to next message
Michel Cadot
Messages: 64122
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
AskTom: getting rows N through M of a result set

Regards
Michel
Re: SQL [message #347763 is a reply to message #347722] Sat, 13 September 2008 15:49 Go to previous messageGo to next message
aniruddha_jathar
Messages: 5
Registered: September 2008
Junior Member
Try this :

select * from
(select rownum r, t.* from table1 t )
where r between 20 and 30;

Thanks,

Aniruddha
Re: SQL [message #347768 is a reply to message #347763] Sat, 13 September 2008 16:08 Go to previous message
Littlefoot
Messages: 20897
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Aniruddha, re-read the first part of Michel's first reply to the original question (message #347724).
Previous Topic: ORA-02180: invalid option for CREATE TABLESPACE
Next Topic: separate decimal point
Goto Forum:
  


Current Time: Wed Dec 07 05:16:17 CST 2016

Total time taken to generate the page: 0.12552 seconds