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? 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. 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; 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 Link to comment https://forums.phpfreaks.com/topic/282178-sum-in-every-individual/#findComment-1449672 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.