The original author seems to be called topcat. I understood it myself and wrote it back with my memory.
If Select Name From StudentTable is used, the result is:
Name
Zhang San
Li Si
If Select ROW_NUMBER () as rowindex, Name From StudentTable is used, the displayed result is
ROWINDEX Name
1 Zhang San
2 Li Si
Of course, you do not need to add numbers to the query results, because the List itself has numbers when displaying data. But the advantage of this is that you can query multiple result sets in the database, and then return them to the customer after the ROWINDEX field is linked together, which is more flexible.
There are also several optional parameters:
1. ROW_NUMBER ()
Example: Select ROW_NUMBER () OVER (order by Name) as rowindex, Name From StudentTable
The result is sorted in sequence.
2. RANK ()
Example: Select RANK () OVER (order by Name) as rowindex, Name From StudentTable
The result is that if five people are called Michael Jacob, then all five are called Michael Jacob, and then the first Mr. Li is called Michael Jacob, and so on.
3. DENSE_RANK ()
Similar to the previous one, the difference is that the first Li Si is No. 2.