how to select 5 to 7 rows from a table, which contains 10 rows?
Answer Posted / soorai ganesh
Should Implement ROW_NUMBER() method.
Just take this Example.
Create table emp(empid int, ename varchar(50),salary numeric
(9,2)
Insert into emp values(1,'Employee1',10000)
Insert into emp values(2,'Employee2',20000)
.
.
Insert into emp values(10,'Employee10',100000)
Consider the above table which have 10 records. Now u
want to select 5,6,7 Rows in this table. Just try this
query.
SELECT E.EmpID,E.EName,E.Salary FROM
(
SELECT ROW_NUMBER() OVER(ORDER BY EmpID ASC) AS Rno, *
FROM emp
) E
WHERE E.Rno >= 5 and E.Rno <= 7
Thats all.
If anyone have other such good idea kindly share........
| Is This Answer Correct ? | 27 Yes | 3 No |
Post New Answer View All Answers
How can you find out how many rows returned in a cursor?
sql database suspect We have a sql database that is showing as suspect. How can we recover?
What are cursors and when they are useful?
What is the sql server 2000 version number?
Explain syntax for viewing trigger?
What is an expression in ms sql server?
how many triggers you can have on a table? : Sql server database administration
What causes index fragmentation?
What are the diifferences between the ms sql server vs mysql?
What happens if time-only values are provided as date and time literals?
Explain cursor as data base object?
What are points to remember while using the fillfactor argument?
Can you name some of the dml commands in sql?
Explain the concept of view and Types of views in SQL server?
Where is my database stored on the hard disk in ms sql server?