How to use ROW_NUMBER Function in SQL Server
By FoxLearn 2/16/2024 4:45:20 AM 100
This post show you how to use ROW_NUMBER Function in SQL Server.
Syntax of the ROW_NUMBER() function:
ROW_NUMBER() OVER ( [PARTITION BY partition_expression, ... ] ORDER BY sort_expression [ASC | DESC], ... )
For example:
SELECT ROW_NUMBER() OVER (ORDER BY FirstName) as Order, FirstName, LastName, City FROM Customers
Result
Order | FirstName | LastName | City |
1 | Lucy | NULL | |
2 | Tom | NewYork |
The ROW_NUMBER() function is useful for pagination, It is a temporary value calculated when the query is run.
- How to export data to .csv file
- How to Read Excel file and Import data from Excel to SQL Server in C#
- How to Create a backup SQL Server in C#
- How to Search data from Database in C#
- How to rename a column name in SQL
- How to add primary key to existing table in SQL Server
- How to add index in SQL Server
- How to Download and Restore Northwind database to SQL Server
Categories
Popular Posts
C# Tutorial
07/20/2024
How to Download Microsoft SQL Server
06/22/2024
What Are RESTful Web Services?
02/19/2024
What is ARM architecture?
04/01/2024