我有这样的结果:
正如你所看到的,我得到了多个相同的结果,我希望每个条件只能获得一行,但我无法实现。
这是我正在使用的查询:
SELECT
frld.[SegAmortisation],
SUM(frld.CurrentLB) over (Partition By frlc.FundReportCategoryId) AS '% of Fund',
frlc.FundReportCategoryId
FROM [dbo].[FundReportLoanData] frld
INNER JOIN [dbo].[FundReportCategories] frlc
ON frld.SegAmortisation = frlc.Description
group by frld.SegAmortisation,
frlc.FundReportCategoryId, frld.CurrentLB
任何想法我怎么能做一些像结果不同的东西,每个FundReportCategoryId只能获得一条记录?
答案 0 :(得分:2)
SELECT
frld.[SegAmortisation],
SUM(frld.CurrentLB) AS '% of Fund',
frlc.FundReportCategoryId
FROM [dbo].[FundReportLoanData] frld
INNER JOIN [dbo].[FundReportCategories] frlc
ON frld.SegAmortisation = frlc.Description
group by
frld.SegAmortisation,
frlc.FundReportCategoryId