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 to integrate the ssrs reports in application?
Your company has 50 branches all over the country all the branches, including the head office have sql server as the database every night all 50 branches upload certain information to the head office which replication topology is best suited for the above scenario?
How to provide default values to stored procedure parameters?
What is bit data type?
What are the disadvantages of using the stored procedures?
What are the differences between ms sql server & oracle?
Can we do dml on views?
How to select an exiting database using mssql_select_db()?
How to move database physical files in ms sql server?
If you want to send some data from access database to sql server database. What are different component of ssis will you use?
What is collation sensitivity? Explain different types.
What part does database design plays a role in performance of an sql server-based application?
What is log shipping? Can we do logshipping with SQL Server 7.0 - Logshipping is a new feature of SQL Server 2000. We should have two SQL Server - Enterprise Editions. From Enterprise Manager we can configure the logshipping. In logshipping the transactional log file from one server is automatically updated into the backup database on the other server. If one server fails, the other server will have the same db and we can use this as the DR (disaster recovery) plan.
How can we check the sql server version?
What is a partition function in sql server?