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.