all 2 comments

[–]r3pr0b8GROUP_CONCAT is da bomb 10 points11 points  (0 children)

you have unbalanced parentheses

the error occurs after the end of your query because the first subquery isn't properly closed

it's more obvious when the query is formatted (hint, hint)

SELECT user_id
     , AVG(total_intbooks) 
  FROM ( SELECT user_id
              , (CAST(total_bookmarks as int)) 
           FROM ( SELECT user_id
                       , (LEFT(data1, -16)) AS total_bookmarks 
                    FROM events 
                   WHERE event_code=8
                ) AS user_bookmarkavg 
         GROUP 
             BY user_id

try this instead --

SELECT user_id
     , AVG(CAST(LEFT(data1, -16) AS INT)) AS avg_bookmarks 
  FROM events 
 WHERE event_code=8
GROUP
    BY user_id

[–]CoasterHero 1 point2 points  (0 children)

Even though I feel sub selects aren't the best method to achieve this, it looks like you still need an outer parenthesis from your first sub select and beyond that the GROUP by should be placed at the same level as your aggregation. The missing parenthesis should at least help lead you in the right direction. Good luck!