SQL select MAX(COUNT)

后端 未结 5 910
梦如初夏
梦如初夏 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:45

    SELECT TOP 1 "name", count(*) AS ItemCount FROM "users" 
    INNER JOIN "microposts" ON "microposts"."user_id" = "users"."id" 
    GROUP BY users.id
    ORDER BY ItemCount DESC
    

提交回复
热议问题