Database grouping function rank () ntile () dense_rank () row_number

Source: Internet
Author: User

--- The rows returned by grouping and sorting may be interrupted in the middle of the positions in the reorganization.
Select fileid, fileclass, userid, rank () over (partition by fileclass order by userid) from files
---- The rows returned by grouping and sorting are not interrupted between the positions in the reorganization. The number of groups is based on the parameters in the ntile (parameter ).
Select fileid, fileclass, userid, ntile (3) over (partition by fileclass order by userid) from files
---- The rows returned by grouping are in the center of the first position in the reorganization.
Select fileid, fileclass, userid, dense_rank () over (partition by fileclass order by userid) from files
---- The rows returned by grouping and sorting are not interrupted in the order position of the reorganization.
Select fileid, fileclass, userid, row_number () over (partition by fileclass order by userid) from files

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.