After Ms sql2005, a number of sequential numbers are added to the query result.
The following example uses the northwind Resource
The parameters are as follows:
1. row_number
Sort by the specified vertex and add the vertex Based on the vertex.
For example:
Select row_number () over (order by customerid) as rowid, * from orders
2. Rank
According to the ranking position, the same information is ranked in the same rank, and the next difference will [skip]
Select rank () over (order by customerid) as rowid, * from orders
3. dense_rank
According to the ranking position, the same information is ranked in the same rank, and the next difference will [skip]
Select -- row_number () over (order by customerid) as ROWID--RANK () over (order by customerid) as rowiddense_rank () over (order by customerid) as rowid, * from orders
Remember me to avoid forgetting