SELECT AVG(totalled) as mySum , `id`
FROM (
SELECT totalled,id
FROM `figure`
where `userid`='".$userid."'
ORDER BY id DESC
LIMIT 4
) t1
I've created this statement but the error I am getting is: Static analysis:
3 errors were found during analysis.
An expression was expected. (near "(" at position 42) Unexpected token. (near "(" at position 42) This type of clause was previously parsed. (near "SELECT" at position 43) SQL query: Documentation
SELECT AVG(totalled) as mySum , `id`
FROM (
SELECT totalled,id
FROM `figure`
where `userid`='".$userid."'
ORDER BY id DESC
LIMIT 4
) t1
MySQL said: Documentation
1140 - In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 't1.id'; this is incompatible with sql_mode=only_full_group_by
What would I have to do to fix this problem.