SQL select MAX(COUNT)

后端 未结 5 905
梦如初夏
梦如初夏 2021-01-18 03:54

I\'m trying to select the user who has the MAX microposts count:

SELECT \"name\", count(*) FROM \"users\" 
  INNER JOIN \"microposts\" ON \"microposts\".\"us         


        
5条回答
  •  情歌与酒
    2021-01-18 04:29

    SELECT x.name, MAX(x.count)
    FROM (
     SELECT "name", count(*)
      FROM "users" INNER JOIN "microposts" ON "microposts"."user_id" = "users"."id"
      GROUP BY users.id
    ) x
    

提交回复
热议问题