GeekInterview.com
Series: Subject: Topic:
Question: 7 of 190

Get 10 and 11th records in the output using SQL in 5 ways ?

I have to tables A and B. My records in this table are in such a way that Table A Table B 10 15 11 16 12 10 13 11 Question :- I want only the 10 and 11 records as my output. Can anyone help me out ( 5 ways to get this output )
Asked by: kalyan.sam | Member Since Jul-2010 | Asked on: Dec 5th, 2011

View all questions by kalyan.sam

Showing Answers 1 - 4 of 4 Answers

Could you expand a little more on the question a little bit more please. I understand that you have two tables, A and B, but... ok so what, are they related? do you want the data filtered for records on each one? What do you mean by "My records in this table are in such a way that Table A Table B 10 15 11 16 12 10 13 11"? That doesnt make sense.

  
Login to rate this answer.
narendar

Answered On : Mar 21st, 2012

For example to retrieve 5th to 10th rows in a table emp

select * from ( select A.*, rowid as R from emp A)
where R>=5 and R<=10

  
Login to rate this answer.
SivaKumar

Answered On : Mar 23rd, 2012

Method 1

Code
  1. SELECT a,employee_id,last_name,first_name,salary FROM
  2. (SELECT ROWNUM AS a,employee_id,last_name,first_name,salary FROM employees)
  3. WHERE a BETWEEN 10 AND 11

  
Login to rate this answer.
hussain

Answered On : Mar 29th, 2012

Code
  1. SELECT * FROM emp WHERE (rowed,0) IN (SELECT rowid,mod(rownum,5) FROM emp);

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.