Cant execute query "SELECT a.galid,a.type,a.caption,a.story,a.setid,a.path,vs.active, IFNULL(AVG(c.rating),0) AS rating, ROUND(IFNULL(AVG(c.rating),0)*10) AS rndrating, COUNT(c.rating) AS votes FROM cms_gals AS a LEFT JOIN cms_gal_sites AS vs ON a.galid=vs.galid LEFT JOIN cms_ratings AS c ON c.contentid=a.galid WHERE a.type='gal' AND vs.secid=86 AND vs.active < UNIX_TIMESTAMP() AND a.galid= GROUP BY a.galid ORDER BY active DESC ;"


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 'GROUP BY a.galid ORDER BY active DESC' at line 12