awebbdesign Posted May 17, 2007 Share Posted May 17, 2007 Just a mysql question... I am trying to sort by a column having a group in it.... SELECT sum(2007_playersresults.score) AS thescore, 2007_playerslist.playerfirstname, 2007_playerslist.playersurname FROM 2007_playersresults LEFT JOIN 2007_playerslist ON 2007_playerslist.playernumber = 2007_playersresults.playernumber GROUP BY 2007_playersresults.playernumber The above works fine... http://www.oxfordauntsally.co.uk/stats_players_all.php?year=2007 But when I add... SELECT sum(2007_playersresults.score) AS thescore, 2007_playerslist.playerfirstname, 2007_playerslist.playersurname FROM 2007_playersresults LEFT JOIN 2007_playerslist ON 2007_playerslist.playernumber = 2007_playersresults.playernumber GROUP BY 2007_playersresults.playernumber ORDER BY 2007_playersresults.score The whole thing crashes! Anybody out there how can help? Quote Link to comment https://forums.phpfreaks.com/topic/51862-solved-order-by-and-group-by/ Share on other sites More sharing options...
pikemsu28 Posted May 17, 2007 Share Posted May 17, 2007 just a thought, shouldnt you do this: ORDER BY thescore since you summed the 2007_playerresults.score and gave it an alias, mysql will recongnize the alias to order by. i'm not 100% sure about that but something to try. Quote Link to comment https://forums.phpfreaks.com/topic/51862-solved-order-by-and-group-by/#findComment-255601 Share on other sites More sharing options...
awebbdesign Posted May 17, 2007 Author Share Posted May 17, 2007 I went all the way round the houses with that little problem! Thanks for your help pal! Though I do feel a bit daft. Quote Link to comment https://forums.phpfreaks.com/topic/51862-solved-order-by-and-group-by/#findComment-255603 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.