woolyg Posted April 2, 2008 Share Posted April 2, 2008 Hi all, I've got a table that logs points assigned to a player, and each player belongs to a league. Please see the image below for the layout: What I want to do is select every player_id from the table, but order them according to the sum total of the points they have accumulated for league_id 1. Can this be done? I've been banging my head off this for days... Thanks, Woolyg Quote Link to comment https://forums.phpfreaks.com/topic/99119-solved-im-not-sure-if-this-can-be-done-but/ Share on other sites More sharing options...
aschk Posted April 2, 2008 Share Posted April 2, 2008 So you want the TOTAL (sum) of ALL the points that each player has accumulated for league 1 ONLY. SELECT player_id ,SUM(points) as 'total' FROM <table name here> WHERE league_id = 1 GROUP BY player_id Quote Link to comment https://forums.phpfreaks.com/topic/99119-solved-im-not-sure-if-this-can-be-done-but/#findComment-507428 Share on other sites More sharing options...
woolyg Posted April 2, 2008 Author Share Posted April 2, 2008 That's right - The total of all points, per player, for league 1 only. After the GROUP BY part, is it possible for me to ORDER BY 'total'? Thanks, WoolyG Quote Link to comment https://forums.phpfreaks.com/topic/99119-solved-im-not-sure-if-this-can-be-done-but/#findComment-507758 Share on other sites More sharing options...
woolyg Posted April 2, 2008 Author Share Posted April 2, 2008 It is! SELECT player_id ,SUM(points) as 'total' FROM game_matches WHERE league_id = 1 GROUP BY player_id ORDER BY total DESC Excellent - thank you so much for your input aschk. Solved. Quote Link to comment https://forums.phpfreaks.com/topic/99119-solved-im-not-sure-if-this-can-be-done-but/#findComment-507762 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.