Re: QUERY rank in query result
Hello,
try this query
SELECT tab.ID, tab.NAME, tab.SCORE, rnk.rank
FROM test.tab tab
JOIN (
SELECT SCORE, ROUND( SUM( ID ) / COUNT(*), 1) RANK
FROM tab
GROUP BY SCORE
) rnk
ON tab.score = rnk.score
ORDER BY id, name;
+ ------- + --------- + ---------- + --------- +
| ID | NAME | SCORE | rank |
+ ------- + --------- + ---------- + --------- +
| 1 | A | 50 | 1.5 |
| 2 | B | 50 | 1.5 |
| 3 | C | 49 | 3.0 |
| 4 | D | 47 | 4.0 |
| 5 | E | 45 | 5.0 |
| 6 | F | 43 | 7.0 |
| 7 | G | 43 | 7.0 |
| 8 | H | 43 | 7.0 |
+ ------- + --------- + ---------- + --------- +
8 rows
Edited 1 time(s). Last edit at 01/02/2012 03:47PM by kordirko kordirko.
Subject
Written By
Posted
December 27, 2011 09:34PM
Re: QUERY rank in query result
January 02, 2012 03:44PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.