我正在尝试选择拥有 MAX microposts 计数的用户:
SELECT "name", count(*) FROM "users"
INNER JOIN "microposts" ON "microposts"."user_id" = "users"."id"
GROUP BY users.id
这会返回
"Delphia Gleichner";15
"Louvenia Bednar IV";10
"Example User";53
"Guadalupe Volkman";20
"Isabella Harvey";30
"Madeline Franecki II";40
但我只想选择"Example User";53
,(拥有 MAX 微博数的用户)
我试图添加HAVING MAX(count*)
,但这没有用。