Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

How can windows applications connect to sql servers via odbc?

1123


What is recursion? Is it possible for a stored procedure to call itself or recursive stored procedure? How many levels of sp nesting are possible?

1004


What are approximate numeric data types in ms sql server?

1054


What is sql server transaction log file?

1054


Can we use trigger new in before insert?

921


How to retrieve error messages using odbc_errormsg()?

1058


What is inline variable assignment?

1021


What is field in algebra?

1036


Which are the two editions in which SQL Azure database available?

119


How many databases Microsoft SQL server provides?

1081


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

1681


What is temporary stored procedure?

941


What is the chart in report?

158


How to access the inserted record of an event?

1049


Explain the use of containers in ssis?

964