How to retrieve range of 10th rows to 20 th rows from total
rows from a database table.? (Not from Dataset)

Answers were Sorted based on User's Feedback



How to retrieve range of 10th rows to 20 th rows from total rows from a database table.? (Not from..

Answer / vinay

SELECT TOP 10
ID,Name,Address
FROM TableName
WHERE ID NOT IN (SELECT TOP 10 ID FROM TableName)

Is This Answer Correct ?    18 Yes 2 No

How to retrieve range of 10th rows to 20 th rows from total rows from a database table.? (Not from..

Answer / govardhana r

use Row_Number() function to check for the condition so
that the row number is between 10 and 20

Is This Answer Correct ?    10 Yes 0 No

How to retrieve range of 10th rows to 20 th rows from total rows from a database table.? (Not from..

Answer / newbie

SELECT E.* FROM
(SELECT ROW_NUMBER() OVER (ORDER BY EmpID) AS RowCounts,
Salary FROM Emp) AS E
WHERE E.RowCounts BETWEEN 10 AND 20

Is This Answer Correct ?    8 Yes 0 No

How to retrieve range of 10th rows to 20 th rows from total rows from a database table.? (Not from..

Answer / santosh dwivedi

select * from
(
select rownum r,a.* from TableName a
)
where r>=10 and r<=20

Is This Answer Correct ?    14 Yes 10 No

How to retrieve range of 10th rows to 20 th rows from total rows from a database table.? (Not from..

Answer / upendra

USE CTE

http://www.4guysfromrolla.com/webtech/071906-1.shtml


WITH CTE_Table AS ( SELECT
Row_number() OVER (
ORDER BY
sort_Column ) AS RowNum
, premiumamount
FROM
shplaninfo )

SELECT
*
FROM
CTE_Table
WHERE
RowNum BETWEEN ( 10 ) AND ( 19 )

Is This Answer Correct ?    5 Yes 2 No

How to retrieve range of 10th rows to 20 th rows from total rows from a database table.? (Not from..

Answer / alex

string myquery="SELECT * FROM [Employee] WHERE
([Table_Field]<=10 AND [Table_Field]<=20)"

Is This Answer Correct ?    2 Yes 0 No

How to retrieve range of 10th rows to 20 th rows from total rows from a database table.? (Not from..

Answer / x.cannon

SELECT * FROM
(
SELECT NTILE(2) AS div, * FROM
(
SELECT TOP(20) FROM <table_name>
) AS tmp
) AS tmp WHERE div = 2

Is This Answer Correct ?    1 Yes 0 No

How to retrieve range of 10th rows to 20 th rows from total rows from a database table.? (Not from..

Answer / shilpa

with temp
as
( select row_number() over(order by city) rowid, * from
employee)
select * from temp
where rowid >= 10
and rowid <= 20

Is This Answer Correct ?    3 Yes 2 No

How to retrieve range of 10th rows to 20 th rows from total rows from a database table.? (Not from..

Answer / adhar jain

With temp As
(
Select columns,
row_number() Over (Order By sort_Column) As row_num
From table
)
Select * from temp where row_num between 10 and 19

Is This Answer Correct ?    2 Yes 1 No

How to retrieve range of 10th rows to 20 th rows from total rows from a database table.? (Not from..

Answer / philip

select Row_Number() over(order by Table_columnName) as
number from TableName where Table_columnName>=10 and
Table_columnName<=20

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

how can you select rexcord(rows) from table A which is not present in Table B . Id being the FK in Table B referencing to ID Table A

0 Answers   United Healthcare,


what is the information that can be stored inside a bit column? : Sql server database administration

0 Answers  


What does this statement do @@rowcount?

0 Answers  


can any one post me, how to remove rows in the below table ENO ENAME EDEPT ELOC 3368 BPS BI Adayar 3371 RAN BI valachari 3369 SRI BI valachari 3372 jay BI Chn - - - - - - - -

2 Answers  


what is the maximum size of a row in sql server 2000 and 2005

2 Answers  






How to convert a table data in XML format in sql server?

0 Answers  


Explain log shipping?

0 Answers  


Explain the advantages of merge replication?

0 Answers  


How to select true false based on column value in sql server?

0 Answers  


What are the types of resultset?

0 Answers  


Do you know what is raid and what are different types of raid configurations? : SQL Server Architecture

0 Answers  


What is live lock and deadlock? what is Lock escalation?

2 Answers   Microsoft,


Categories