ORDER BY descending desc, ascending ASC, Rank function rank () over () _order-by

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.