SELECT n.nid, n.title, u.name, n.created, n.changed, l.comment_count, flexinode_7.textual_data AS flexinode_7, (SELECT AVG(value) FROM {votingapi_vote} v WHERE v.value_type = 'percent' AND v.content_type = 'node' AND v.content_id = n.nid) AS avgval FROM {node} n LEFT JOIN {flexinode_data} flexinode_7 ON n.nid = flexinode_7.nid INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 AND n.type = 'flexinode-2' AND flexinode_7.field_id = 7ORDER BY n.title ASCYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AS avgval FROM node n LEFT JOIN flexinode_data flexinode_7 ON n.nid = flexinod' at line 1 query: SELECT COUNT(*) FROM votingapi_vote v WHERE v.value_type = 'percent' AND v.content_type = 'node' AND v.content_id = n.nid) AS avgval FROM node n LEFT JOIN flexinode_data flexinode_7 ON n.nid = flexinode_7.nid INNER JOIN users u ON u.uid = n.uid INNER JOIN node_comment_statistics l ON n.nid = l.nid WHERE n.status = 1 AND n.type = 'flexinode-2' AND flexinode_7.field_id = 7 in ... line ...