ORDER BY descending desc, ascending ASC by age descending
Select *from Student ORDER BY age DESC
Ascending by age
Select *from Student ORDER BY age ASC
Rank function rank () in descending order of use age, if the sort field is the same, rank equal
Select *,rank () over (DESC) as rank from student
Sorted by age after sex grouping, equal rank if the sort field is the same
Partition by group
Select *,rank () over (partition by sex ORDER BY age desc) as rank from student
The age is sorted by default (ascending) according to the result set, and the following order by is not related to the preceding rank () over ()
Select *,rank () over (partition by sex ORDER BY age desc) as rank from student
Rank function row_number () over () Use age descending sort, if the sort field is the same, the rank is cumulative
Select *,row_number () over (DESC) as rank from student
After sex grouping by age descending sort, if the sort field is the same, the rank cumulative partition by group
Select *,row_number () over (partition by sex ORDER BY age desc) as rank from student
The age is sorted by default (ascending) according to the result set, and the following order by is not related to the preceding rank () over ()
Select *,row_number () over (partition by sex ORDER BY age desc) as rank from student