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
Name the different type of indexes in sql?
is there a column to which a default can't be bound? : Sql server database administration
What are the dmvs? : sql server database administration
How to divide query output into multiple groups with the group by clause in ms sql server?
Explain the concept of recursive stored procedure.
What is difference between materialized view and view?
Do you know what are pages and extents? : SQL Server Architecture
What are binary string data types in ms sql server?
What does the update command do?
What is trigger and different types of Triggers?
What command is used to delete a table from the database in the sql server and how?
What are rows and columns?
What is the difference between varchar and varchar(max) datatypes?
How to create a view on an existing table in ms sql server?
What is the full meaning of dml?