Hello Tom,
I was looking for a solution to use with the rank (or dense_rank) function. I need to have every row receive a distinct rank dispite frequent ties in the data. I would like to arbitrarily assign a rank in the event of a tie, using either the order of occurance or revert to alphabetical in terms of the key.
For example, suppose i have the following table:
CREATE TABLE sales_by_employee (name VARCHAR2(10), sales NUMBER);
that contains the following data:
INSERT INTO sales_by_employee VALUES ('dave', 500);
INSERT INTO sales_by_employee VALUES ('walter', 400);
INSERT INTO sales_by_employee VALUES ('jack', 400);
INSERT INTO sales_by_employee VALUES ('sue', 300);
I would like to produce a report that looks like this:
NAME SALES RANK
dave 500 1
walter 400 2 <-- tie is resolved
jack 400 3 <-- tie is resolved
sue 300 4
Note that the tie was resolved in favor of 'walter' simply because his record was first (I also wouldn't care if it put 'jack' first due to alphabetical precidence).
I searched your site and that the following were the most helpful, but did not ever fully answer this:
</code>
http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:2920665938600 http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:12759079666984 <code>
Further, in the documentation there was something about a "TIEBREAKERS" clause, but couldn't find any examples. (i think its for use with OLAP).
Any suggestions?