Re: Grouping only top 10 values
Something like the following, but I haven't tested this:
SELECT ptop10.player_id, SUM(ptop10.player_points) AS total
FROM (
SELECT p.player_id, p.player_points
FROM player_table p
LEFT JOIN player_table p2 ON p.player_id = p2.player_id
AND p.player_points <= p2.player_points
GROUP BY player_id, player_points
HAVING COUNT(*) <= 10
) AS ptop10
GROUP BY ptop10.player_id
ORDER BY total DESC
This is the best I can think of, but it still doesn't work for what you want. If the player's 10th and 11th highest score are the same, for instance, both will be excluded from the subtotal. Furthermore, this means that if all of the player's top 11 scores are identical, the whole lot will be excluded, and the player won't show up in the report at all.
So I'm not sure there is a solution in a single query.
Regards,
Bill K.
Subject
Written By
Posted
Re: Grouping only top 10 values
June 29, 2006 06:34PM
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.