Yohanne Posted September 16, 2013 Share Posted September 16, 2013 Hi coders, do you think it is possible to get the sum of every Individual like below? Quote Link to comment https://forums.phpfreaks.com/topic/282178-sum-in-every-individual/ Share on other sites More sharing options...
kicken Posted September 16, 2013 Share Posted September 16, 2013 Yes. How depends on where your data comes from. If you're using Mysql and have a query to return the data, just add in a GROUP BY clause and SUM() function. Otherwise group the data into an array in PHP with a total variable for each group. Quote Link to comment https://forums.phpfreaks.com/topic/282178-sum-in-every-individual/#findComment-1449644 Share on other sites More sharing options...
priyankagound Posted September 16, 2013 Share Posted September 16, 2013 You need to add a GROUP BY clause to get the sum() for each player: eg: SELECT Player.PlayerName, SUM(COALESCE(Exp.ExpChange, 0)) AS expFROM PlayerLEFT JOIN ExpON Player.PlayerID=Exp.PlayerIDGROUP BY Player.PlayerNameORDER BY exp; Quote Link to comment https://forums.phpfreaks.com/topic/282178-sum-in-every-individual/#findComment-1449667 Share on other sites More sharing options...
Barand Posted September 16, 2013 Share Posted September 16, 2013 TIP: Avoid column names such as "desc". DESC is a reserved word in SQL Quote Link to comment https://forums.phpfreaks.com/topic/282178-sum-in-every-individual/#findComment-1449672 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.