how to get 25th row in any table in sqlserver can u tell me
syntax

Answer Posted / anand k

For Ex. We are Using State Table for this scenario.

Records In State Table is (Total 50 Rec)
Alabama
Alaska
Arizona
Arkansas
California
Colorado
Connecticut
Delaware
Florida
Georgia
Hawaii
Idaho
Illinois
Indiana
Iowa
Kansas
Kentucky
Louisiana
Maine
Maryland
Massachusetts
Michigan
Minnesota
Mississippi
Missouri
Montana
Nebraska
Nevada
New Hampshire
New Jersey
New Mexico
New York
North Carolina
North Dakota
Ohio
Oklahoma
Oregon
Pennsylvania
Rhode Island
South Carolina
South Dakota
Tennessee
Texas
Utah
Vermont
Virginia
Washington
West Virginia
Wisconsin
Wyoming
--------

Now we are Selecting 25th record from the state table.

SELECT STA.*
FROM [State] STA,
(SELECT StateName,ROW_NUMBER() OVER (ORDER BY StateName)
ROWNO FROM [State] ) ROW
WHERE ROW.ROWNO = 25
AND ROW.StateNAme = STA.StateName
ORDER BY StateName

Is This Answer Correct ?    4 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Name the different type of indexes in sql?

534


is there a column to which a default can't be bound? : Sql server database administration

541


What are the dmvs? : sql server database administration

600


How to divide query output into multiple groups with the group by clause in ms sql server?

570


Explain the concept of recursive stored procedure.

497






What is difference between materialized view and view?

494


Do you know what are pages and extents? : SQL Server Architecture

554


What are binary string data types in ms sql server?

658


What does the update command do?

617


What is trigger and different types of Triggers?

578


What command is used to delete a table from the database in the sql server and how?

546


What are rows and columns?

524


What is the difference between varchar and varchar(max) datatypes?

563


How to create a view on an existing table in ms sql server?

594


What is the full meaning of dml?

532