Sort functions:
1.row_number () over (ordered by Liename): A unique line number is given for each row, sorted by the field following order by
Select Row_number () over (order by iname Desc) as ROWID, iname from test
2.Rank (): The field values are the same with the same ordinal number, and the ordinal number may be discontinuous, according to the field following the order by
Select DISTINCT rank (iname desc) as ROWID, iname,iage from test
3. Dense_rank (): According to the order by the field after ordering by, the field value after the orders by the same ordinal number is the same, serial number is continuous
SELECT DISTINCT Dense_rank () over (order by iname Desc) as ROWID, iname from test
4. Ntile (): First, according to the order by the field after the sort, and then the sorting results into a set of several groups, and for each group to specify a group number
SELECT DISTINCT Ntile (5) over (order by iname Desc) as rowID iname,iage
Summarize:
1.row_number () over (ordered by Liename): A unique line number is given for each row, sorted by the field following order by
2.Rank (): The field values are the same with the same ordinal number, and the ordinal number may be discontinuous, according to the field following the order by
3. Dense_rank (): According to the order by the field after ordering by, the field value after the orders by the same ordinal number is the same, serial number is continuous
4. Ntile (): First, according to the order by the field after the sort, and then the sorting results into a set of several groups, and for each group to specify a group number