GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Oracle  >  SQL
Go To First  |  Previous Question  |  Next Question 
 SQL  |  Question 74 of 171    Print  
How to get first 5 Records then next 5 records till end of row count in SQL -Oracle

  
Total Answers and Comments: 10 Last Update: March 06, 2009     Asked by: Dev 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
February 09, 2006 00:47:42   #1  
gayu_rec Member Since: February 2006   Contribution: 3    

RE: How to get first 5 Records then next 5 records til...
Use ROWNUM to get the rows one set after the other as mentioned in the question
 
Is this answer useful? Yes | No
February 28, 2006 07:59:29   #2  
Mainak Aich        

RE: How to get first 5 Records then next 5 records til...

We can get the first 5 records by the following sql:(Let the table is emp)

select * from emp where rownum<6

Then we can get the next 5 records by the following sql:

select * from emp where rownum<6 MINUS select * from emp where rownum<11

and so on...


 
Is this answer useful? Yes | No
March 04, 2006 02:23:19   #3  
KS        

RE: How to get first 5 Records then next 5 records til...
It should be:Select * from emp where rownum<6;thenSelect * from emp where rownum<11 MINUS select * from emp where rownum <6;and so on
 
Is this answer useful? Yes | No
April 04, 2006 12:46:01   #4  
reddeppa        

hai
select * from emp where not in (select rownum betwen 5 and count(rownum)-5 from emp)
 
Is this answer useful? Yes | No
May 05, 2006 07:51:06   #5  
amrita        

RE: How to get first 5 Records then next 5 records til...

hello your answer is correct but the sequence is wrong

To get first five records

select aud_trn_issue_header.* rownum from aud_trn_issue_header where rownum < 6

To get the next five records

select aud_trn_issue_header.* rownum from aud_trn_issue_header where rownum < 11 minus
select aud_trn_issue_header.* rownum from aud_trn_issue_header where rownum<6

and so on..............

bye


 
Is this answer useful? Yes | No
May 06, 2006 07:51:03   #6  
Santhosh        

RE: How to get first 5 Records then next 5 records til...

Hello

Please post correct queries after checking.


 
Is this answer useful? Yes | No
June 07, 2006 04:24:28   #7  
Al Di Meola        

RE: How to get first 5 Records then next 5 records til...

select * from

(select rownum rowpos emp.* from emp) inline_emp

where inline_emp.rowpos between 5 and 10

This should work for any rownum range......

~Al Di Meola


 
Is this answer useful? Yes | No
October 27, 2006 07:29:58   #8  
cgk1983 Member Since: March 2006   Contribution: 1    

RE: How to get first 5 Records then next 5 records til...

select A.R A.ename from (select rownum R ename from emp)A where A.r between &start and &end
/


 
Is this answer useful? Yes | No
May 22, 2007 07:19:30   #9  
Sandeep Bawalia        

RE: How to get first 5 Records then next 5 records til...
select d.amount from (select t.tadichallan_amt amount rank() over (order by t.tadichallan_amt desc) as Rank1
from tae_challan_det t where t.tadichallan_amt is not null )d
where Rank1 between '&n' and '&d'


 
Is this answer useful? Yes | No
March 06, 2009 01:21:39   #10  
sharmasl Member Since: March 2009   Contribution: 10    

RE: How to get first 5 Records then next 5 records till end of row count in SQL -Oracle
Please Try This Query on SQL Prompt And see the best result as per Requirement.

select * from
(select rownum rowno emp.* from emp) line_emp where line_emp.rowno between &a and &b;

Thanks
Salil Sharma


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape