List:General Discussion« Previous MessageNext Message »
From:Ananda Kumar Date:September 9 2010 1:25pm
Subject:Re: Query SUM help
View as plain text  
try using the RANK function...

something like select * from table order by RANK desc limit 11.....this will
get u the top 11 rows.

regards
anandkl

On Thu, Sep 9, 2010 at 1:55 PM, Tompkins Neil
<neil.tompkins@stripped>wrote:

> Yes, but it doesn't work.  Basically I want the SUM(players_master.rating)
> only to SUM the top 11 players from each team.  Any suggestions ?
>
> Cheers
> Neil
>
>
> On Thu, Sep 9, 2010 at 9:17 AM, Ananda Kumar <anandkl@stripped> wrote:
>
>> did u try to use  LIMIT after ORDER BY
>>
>>
>> On Thu, Sep 9, 2010 at 1:27 PM, Tompkins Neil <
>> neil.tompkins@stripped> wrote:
>>
>>> Any help would be really appreciated ?
>>>
>>>
>>>
>>> ---------- Forwarded message ----------
>>> From: Tompkins Neil <neil.tompkins@stripped>
>>> Date: Wed, Sep 8, 2010 at 5:30 PM
>>> Subject: Query SUM help
>>> To: "[MySQL]" <mysql@stripped>
>>>
>>>
>>> Hi
>>>
>>> I've the following query :
>>>
>>> SELECT total_team_rating, my_teams_id
>>> FROM
>>> (SELECT players.teams_id AS my_teams_id, SUM(players_master.rating) AS
>>> total_team_rating
>>> FROM players
>>> INNER JOIN players_master ON players.players_id =
>>> players_master.players_id
>>> WHERE players.worlds_id = 1 AND players.red_cards = 0 AND
>>> players.injury_duration_remaining = 0
>>> GROUP BY players.teams_id) s1
>>> ORDER BY s1.total_team_rating DESC
>>>
>>> This gives me the total of players_master.rating for each
>>> players.teams_id.
>>>  However, I'm wanting to only base the players_master.rating on the top
>>> 11
>>> records in the players table for each team.  How can I modify my query to
>>> achieve this ?
>>>
>>> Thanks
>>> Neil
>>>
>>
>>
>

Thread
Query SUM helpTompkins Neil8 Sep
  • Fwd: Query SUM helpTompkins Neil9 Sep
    • Re: Query SUM helpAnanda Kumar9 Sep
      • Re: Query SUM helpTompkins Neil9 Sep
        • Re: Query SUM helpAnanda Kumar9 Sep
    • Re: Query SUM helpAnanda Kumar9 Sep
    • Re: Query SUM helpAnanda Kumar9 Sep
    • Re: Fwd: Query SUM helpMySQL)9 Sep
    • RE: Query SUM helpTravis Ard9 Sep