How to use ROW_NUMBER Function in SQL Server
By FoxLearn 2/16/2024 4:45:20 AM 194
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 convert varchar to uniqueidentifier in SQL Server
- JDBC sqlserver connection string
- Connection string odbc
- How to convert datetime to date (with time set to 00:00:00.000) in SQL
- How to set time to 00:00:00 with GETDATE() in SQL
- How to convert varchar to integer in MySQL
- How to fix 'string or binary data would be truncated' in sql
- How to Restore SQL Database Backup in C#
Categories
Popular Posts
How to sign a powershell script
10/03/2024
How to get Credentials in PowerShell?
10/03/2024
How to implement Jint in C#
09/14/2024