选择 市, usd_spent / count(city)AS avg_spent 来自travel_spending 按城市分组的avg_spent> 90;
答案 0 :(得分:0)
某些版本的SQL(例如MySQL)允许在HAVING
子句中使用别名,而其他版本(例如SQL Server)则不允许。无论如何,只要在HAVING
子句中重复聚合表达式就可以:
SELECT city, AVG(usd_spent) AS avg_spent
FROM travel_spending
GROUP BY city
HAVING AVG(usd_spent) > 90;