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
can you implement data mining in SSRS?
How each E-R model constructs can be mapped to the relational model?
how would you write a sql query to compute a frequency table of a certain attribute involving two joins? What changes would you need to make if you want to order by or group by some attribute? What would you do to account for nulls?
Can we create clustered index on composite key?
Write SQL queries on Self Join and Inner Join.
How will you make an attribute not process? : sql server analysis services, ssas
How to view existing indexes on an given table using sys.indexes?
Explain trigger and trigger types?
What is difference between sql and sql server?
Explain powershell included in sql server 2008?
How will you find out if there are expensive SQL statements running or not?
What is the use of @@spid?
How to find related tables in sql server?
Give me a SQL Query to find out the second largest company?
How do I schedule a sql server profiler trace?