List:General Discussion« Previous MessageNext Message »
From:Tompkins Neil Date:September 25 2010 10:35pm
Subject:Advanced query help
View as plain text  
Hi,

I've the following query

SELECT teams_id AS teams_id ,SUM(rating) AS total_team_rating FROM (SELECT
teams_id ,players_id ,rating ,IF(@team <> teams_id, @row := 1, @row := @row
+ 1) AS rank ,@team := teams_id FROM ( SELECT players.teams_id
,players.players_id ,players_master.rating FROM players 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 AND
players.teams_id > 0 ORDER BY players.teams_id, players_master.rating DESC)
s1) s2 WHERE rank <= 11 GROUP BY teams_id ORDER BY total_team_rating DESC

I'm running MySQL 5.0.77.  However, if I run this query nothing is returned,
but if I run the query again I get the desired results.  Why is this ?

Cheers
Neil

Thread
Advanced query helpTompkins Neil26 Sep
  • Re: Advanced query helpJohan De Meersman27 Sep
    • Re: Advanced query helpTompkins Neil27 Sep
      • Re: Advanced query helpJohan De Meersman27 Sep