Skip navigation links

MySQL Forums :: Newbie :: Grouping only top 10 values


Advanced Search

Grouping only top 10 values
Posted by: Paul ()
Date: June 29, 2006 05:41PM

Hello,

I am trying to figure out how to run something complex like this:

my table structure is similar to this:

player_id
player_points

each player has alot of rows with points.

The way we have our listings displayed is by doing a

SELECT player_id, SUM(player_points) as total GROUP BY player_id ORDER BY total DESC.

This works great but now we need to change our queries to reflect only top 10 scores of each player. So if a player has 50 entries for different points, we need to grab only the top 10 points and find the sum of that. Our table has over 20 million rows.

Can anyone guide me on how I would go on doing this? One way is by passing row by row into php and counting only top 10 rows. But this means going through all 20 million rows through php, very ineffective.

Any hints?

thank you

Options: ReplyQuote


Subject Written By Posted
Grouping only top 10 values Paul 06/29/2006 05:41PM
Re: Grouping only top 10 values Bill Karwin 06/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.