SELECT count([User_Id]) counts ,[User_Id]
FROM [dbo].[ServiceProviderEvaluates] group by [User_Id] order by counts desc
GO
查询结果如下
counts User_Id
15 bb0789d8-181a-4fce-bee9-e3717c3ff24d
6 16c377c0-2469-43ce-86cb-443af1494378
4 2ec6c026-d825-42d8-9068-2f46d121c323
2 6b4752d7-08c5-4bea-bc5f-5df0a6d6f4dd
1 0fc53d7c-6a4d-4bf5-bcc2-836cc7156ef4
请问,如何获取用户ID ‘2ec6c026-d825-42d8-9068-2f46d121c323’ 所在的行号
最后结果是:3
在ef的结果中使用indexOf
再套一层,就行来呗
select counts ,[User_Id],row_number() over(order by counts desc) row_no from ( SELECT count([User_Id]) counts ,[User_Id] FROM [dbo].[ServiceProviderEvaluates] group by [User_Id] ) order by counts desc