"SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') a left join lotr_deck_ratings dr on a.id = dr.deck_id group by a.id) b left jo' at line 1 (SQL: select count(*) as aggregate from (SELECT ifnull(sum(views), 0) as views, b.* from (select (sum(rating = 1) - sum(rating = 0)) as ratings, a.* from (select users.name as username, decks.* from lotr_decks decks left join users on decks.user_id = users.id where decks.user_id = ) a left join lotr_deck_ratings dr on a.id = dr.deck_id group by a.id) b left join lotr_deck_views dv on b.id = dv.deck_id group by b.id) c)"