Several examples of Oracle over functions

Source: Internet
Author: User

The data used for the test is the EMP table in Scott/tiger mode:

We use the job and sal two column tests:

The above statement refers to the job placement group (partition by job) and then ranks within each group by salary (SAL). Notice the juxtaposition, for example, of the occupation of Slaesman, there are two 1250 tied first, 1500 is the 3rd place.

Change rank () to Dense_rand to see the difference:

It can be seen that in dealing with side-by-side issues, the rank is not occupied by the rank number.

Another common analysis function is sum () over:

SUM () over calculates the cumulative sum, starting with the first line, accumulating the value of the SAL column, noting that the order by Sal, if not sorted by Sal, results in the following:

If you want to accumulate sums separately for each grouping, simply add the partition partition by:

Several examples of Oracle over functions

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.