You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'hospitalRating DESC LIMIT 20' at line 8
Query: SELECT hospitals.*,companies.name companyName,AVG(ratings.rating) hospitalRating FROM c4p_hospitals hospitals JOIN c4p_companies companies USING(companyId) LEFT JOIN `c4p_ratings` ratings USING(hospitalId) WHERE hospitals.status = 1 AND 1 = 1 GROUP BY hospitalId ORDER BY ,hospitalRating DESC LIMIT 20