我有以下最终选择语句:
SELECT ReportingDate
,PortfolioID
,IssueNme
,ROW_NUMBER() OVER (PARTITION BY PortfolioID ORDER BY SUM(Percentage) DESC) AS [Rank]
,CAST(SUM(Percentage) AS DECIMAL(22,1)) AS [Weight]
FROM @Worktable as WT
WHERE WT.IssueType1 IN ('020')
GROUP BY WT.ReportingDate, WT.PortfolioID, WT.IssueNme
ORDER BY [Weight] DESC
但是,我只想查看每个组合 ID 的前 10 名。我将如何做到这一点,以确保我获得分组的每个 PortfolioID 的前 10 名?