Rank () over () ranking in Oracle

Source: Internet
Author: User

Today I encountered a problem:

Code:

select row_no, roleid, roleName  from (select roleid,               roleName,               rank() over(order by sum(decode(roundrs, 1, 40, 2, 20, 3, -10, 0, 20, 0)) + 50 desc, sum(decode(roundrs, 1, 1, 0)) desc, sum(decode(roundrs, 3, 1, 0))) row_no          from (select roleId, roleName, roundIndex, roundRs                  from tblContestResult                 where term = 65                   and vocation = 1                   and levelnum = 1                 group by roleId, roleName, roundIndex, roundRs)         group by roleid, roleName) where row_no <= 3;

--- Rank () over (order by column name sorting) results are not consecutive. For example, if there are four people, two of them are tied for 1st, then the final sorting result is as follows: 1 1 3 4.

The use of this function leads to a strange phenomenon: SQL tool query is no problem, the use of Java program query in the loop to the specified number of times, the database returns an error: ORA-00942 (cannot find the table or view). This problem is reflected in the DBA's feedback. This is a bug in rank () over in Oracle products. Of course, the DBA will solve this problem soon and the program will not report an error. It is unknown how DBAs solve the problem. This is a special record. The specific reason is time for further research.

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.