In a database, I have fields for scoring users. They are as following:
id | user_id | month | week | activity | speed
So, I want to get activity+speed in one field, BUT from a GROUP_CONCAT results, as I have more than one scoring, for one user (different week & month).
My current query is as following:
SELECT *, GROUP_CONCAT( CONVERT( tfts_bodovanja.activity + tfts_bodovanja.speed,
CHAR( 8 ) ) SEPARATOR '+' ) AS indeks
FROM tfts_fans
GROUP BY user_id
ORDER BY indeks DESC
And it returns (for the bolded part):
191.4000+383.1999
And ordering doesn’t work, obviously.
So, all I want is just to sum up those two numbers and mysql to return them as FLOAT. How is that achievable?
GROUP_CONCAT with a “+” will create a string and won’t do an addition. Assuming you want the sum of (activity+speed) for each user you can do something like this