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
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 |
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 |
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 |
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 |
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 |
Answer / alex
string myquery="SELECT * FROM [Employee] WHERE
([Table_Field]<=10 AND [Table_Field]<=20)"
| Is This Answer Correct ? | 2 Yes | 0 No |
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 |
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 |
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 |
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 |
How to select some specific columns from a table in a query in ms sql server?
What is an indexing strategy?
How and why use sql server?
Distinguish between commit and rollback?
How can you swap values between two rows in a table using single- SQL statement?
1 Answers Tavant Technologies, Virtusa,
How to avoid cursors?
3 Answers CarrizalSoft Technologies, HP,
What is a Linked Server?
statement (of account) Receive ID_receive Date_receive Amount_receive TO_receive From_receive Description_receive 1 2010/01/01 500 Bank Ahmed Payment from the account 2 2010/02/01 700 Bank Ahmed Payment from the account Payment ID_payment Date_payment Amount_payment From_payment To_payment Description_payment 1 2010/03/01 1000 Ahmed Sales Sale goods 2 2010/04/01 1500 Ahmed Sales Sale goods How can crate Stored Procedures for the statement (of account) from these tables? I want statement (of account) like this: (in sql 2005) ID_ name description debit account credit account balance
How will you monitor replication activity and performance? What privilege do you need to use replication monitor? : sql server replication
What is the recovery model?
how to find the second salary?
How do you know which index a table is using?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)