这是我的疑问:
SELECT AVG(user_reviews.rate) AS SQLAVG,facilities_stores.*
FROM `facilities_stores`
LEFT JOIN user_reviews ON user_reviews.facility_id = facilities_stores.id
WHERE facilities_stores.id IN (17,20,21,35)
GROUP BY facilities_stores.id ORDER BY SQLAVG DESC
如果是SUM或COUNT。此查询工作正常。
但是当AVG无法正常工作时。
此查询与Mysql< 5.6。我不确定我错了。
看起来在Mysql 5.7中ORDER BY
与GROUP BY
这是我的结果