Error!

MySQL Error: 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 address_countries.name ORDER BY address_countries.name asc' at line 1SQL Statement: SELECT address_countries.*, count(DISTINCT contents.id) as count FROM contents JOIN content_taxonomy on content_taxonomy.content_id = contents.id JOIN bgcompanies on bgcompanies.id=contents.id JOIN locations on bgcompanies.display_address=locations.id JOIN address_countries on address_countries.iso_code=locations.country WHERE contents.content_type_id = 2543 AND address_countries.iso_code!='' and contents.publish_date <= '2016-12-09 09:00:00' and contents.published=1 and contents.magazine_id=5 AND content_taxonomy.taxonomy_id = group by address_countries.name ORDER BY address_countries.name asc