I know this is old, but the error position is stated right in the message ...
This comma does not belong (right after "totals") ...
(COUNT(user_id)) as totals, FROM