SELECT a.fId,a.f志工Id,a.f志工名稱,a.f服務時數,dense_rank() over (PARTITION BY a.f志工Id ORDER BY a.fId) Rank
FROM iLive.dbo.t志工服務 as a
INNER JOIN (SELECT TOP 10 f志工Id, count(*) as c
FROM iLive.dbo.t志工服務
GROUP BY f志工Id
ORDER BY count(*) desc) as b
ON a.f志工Id = b.f志工Id
ORDER BY b.c DESC
沒有留言:
張貼留言