Background:
In the paging feature, the record needs to be paginated, and the Row_number () function is required to mark the line number.
Data sheet:
Before sorting the data table shows:
SQL statements:
1 Select as from T1
Search results:
Note: The ID of the Leslie is null, and after sorting, rows is promoted to the first place.
Common error: Column name rownum invalid.
Explanation: In SQL, the hot name (that is, the name rownum) cannot be used immediately, and a layer of queries needs to be wrapped.
For example: To achieve paging, only want to query the results of 1-5 rows, SQL statements are as follows:
1 Select as from where 1 5
Solution:
1 Select from 2 (select as from T1) U3where1 5;
That is
1 as 2 (3Select as from T14) 5 Select from where 1 5;
Search results:
Reference: Hot Name
SQL uses row_number () query to mark line numbers