ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Databases  >>  SQL Server
 
 


 

 
 Oracle interview questions  Oracle Interview Questions
 SQL Server interview questions  SQL Server Interview Questions
 MS Access interview questions  MS Access Interview Questions
 MySQL interview questions  MySQL Interview Questions
 Postgre interview questions  Postgre Interview Questions
 Sybase interview questions  Sybase Interview Questions
 DB Architecture interview questions  DB Architecture Interview Questions
 DB Administration interview questions  DB Administration Interview Questions
 DB Development interview questions  DB Development Interview Questions
 SQL PLSQL interview questions  SQL PLSQL Interview Questions
 Databases AllOther interview questions  Databases AllOther Interview Questions
Question
How to select nth record from a table?
 Question Submitted By :: Durga Prasad
I also faced this Question!!     Rank Answer Posted By  
 
  Re: How to select nth record from a table?
Answer
# 1
SELECT * FROM
(
SELECT ROW_NUMBER() OVER(ORDER BY column_name) AS Rno,*
FROM Table_Name
)T
WHERE T.Rno = 7  -- If N is 7 other wise put ur nth value.
 
Is This Answer Correct ?    23 Yes 1 No
Soorai Ganesh
 
  Re: How to select nth record from a table?
Answer
# 2
--For ex in dept table to select 5th record. Instead of 
this you can use &n so that it can ask row number

  select rnum, d.* from dept d, (select rownum rnum , 
deptno from dept ) e
where d.deptno = e.deptno and rnum = 5
 
Is This Answer Correct ?    3 Yes 6 No
Sajida
 
 
 
  Re: How to select nth record from a table?
Answer
# 3
declare @querry nvarchar(500)
declare @row varchar(10)
set @row = '5'

set @querry ='
select top 1 a.* from 
(select * from vdpmaster..usermaster
	 where usr_id not in
				(select top '
set @querry = @querry + @row + ' usr_id from 
vdpmaster..usermaster)
)a'
print @querry
EXEC sp_executesql @querry
 
Is This Answer Correct ?    1 Yes 1 No
Mohan Krishna
 
  Re: How to select nth record from a table?
Answer
# 4
Select top 1 * from 
(Select top n * from tbl order by column name asc)tbl1 
order by column name desc
 
Is This Answer Correct ?    9 Yes 3 No
Saravanan P
 
  Re: How to select nth record from a table?
Answer
# 5
select * from 
(select row_number() over(order by empid) rno,* from tbl)
tbl1
where tbl1.rno=n
 
Is This Answer Correct ?    3 Yes 3 No
Saravanan P
 
  Re: How to select nth record from a table?
Answer
# 6
Here N is for Nth record.

SELECT TOP 1 * FROM
     (SELECT TOP N * FROM 
        (SELECT Table.Coloumn1,Table.Coloumn2 from Table)
as d order by d.Coloumn1 desc) as p order by Coloumn1
 
Is This Answer Correct ?    5 Yes 2 No
Pallavi Attarde
 
  Re: How to select nth record from a table?
Answer
# 7
select top 1 * from (select top n * from tbl order by col1 
desc) tbl order by col1 asc

where n = nth number in the list
 
Is This Answer Correct ?    2 Yes 2 No
Roxy
 
  Re: How to select nth record from a table?
Answer
# 8
select a.id,a.name from dept a
where
1= (select COUNT(b.id) from dept b where b.id>a.id)
 
Is This Answer Correct ?    1 Yes 0 No
Andy
 
  Re: How to select nth record from a table?
Answer
# 9
Answer #7 should be 

select top 1 * from (select top n * from tbl order by col1 
asc) tbl order by col1 desc

where n = nth number in the list
 
Is This Answer Correct ?    2 Yes 1 No
Rathika
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
Hi Can any one tell me the Good institute to learn SQL esp for Data Base Testing or SQL from scratch to the proficiency level in Hyederabad and facult also. Thankyou well in advance  6
system date format is "yy-mm-dd" "select getdate()" ----> 2009-01-24 20:03:28.513 if i write "select dateadd(dd,2,getdate()) ".it returns "2009-01-26 19:59:38.340"...my question is dat could it be possible to retrive da date in da format "26 jan 2009 ...."??  8
i have 4 tables.. T1, T2, T3, T4.. these tables have the same structure and they store the information entered in different years.. T1 stored 2002, T2 stored 2003, T3 stored 2004 and T4 stored 2005.. i want to copy contents in T1 to T2, T2 to T3, T3 to T4 and T4 to T1.. how do i do that? Temp tables cannot be used..  2
What are the different types of replication? How are they used?  3
Which command using Query Analyzer will give you the version of SQL server and operating system?  3
What types of integrity are enforced by a foreign-key constraint  1
Explain different isolation levels?  3
What is a materialized view?  2
please can anyone answer this query Table 1 has 2 columns: EmployeeId,Age Table 2 has 2 columns: EmployeeId, Region Write SQL to Find the region who has the oldest person  7
What are the differences between stored procedure and functions in SQL Server 2000? TCS12
What is a stored procedure?  3
Display a roll having miminum marks in two subjects? Patni7
what operator performs pattern matching?  1
Alternative way to DetDate() function?  4
in emptable i want to retrive the name of employee whose name in 'J'char.exp: arjun,jagadesh,niranjan,anju,aaaj etc.  7
what is curser.  8
Differnce between sel server 2000 and 2005  3
Explain Trigger with an example?  1
What is the difference between OLEDB and ODBC CFCI3
I Have Employee table having column name as ID,SALARY how to get second max salary from employee table with id ex ID SALARY 1 20000 7 37000 2 5000  11
 
For more SQL Server Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com