我有以下查询来生成学生的经济援助奖励表。我们想做一个 Pivot,因为我们想同时显示多个学期的帮助。
select pt.award as Award, pt.[1] as Fall, pt.[2] as Spring, pt.[3] as Summer
--into #awardTemp
from (select fa.Description as award, fa.OriginalAmount, fa.TextTerm,
ROW_NUMBER() OVER(PARTITION BY fa.description
order by fa.textterm) AS M
from CAMS_Enterprise.dbo.cams_FinancialAward_view as fa
where fa.Code1ID = 0
and fa.StudentAccepted is null
and fa.studentuid = @studentuid) as AT
pivot (max(at.originalamount) for at.m in ([1],[2],[3])) as pt
我们没有在同一行列出每学期的金额,而是得到如下所示的结果。即使描述标题相同,每个学期的奖项都有自己的行。有谁知道问题出在哪里?
Academic Scholarship 5000.00 NULL NULL
Academic Scholarship NULL 5000.00 NULL
Federal Subsidized Stafford Loan 1750.00 NULL NULL
Federal Subsidized Stafford Loan NULL 1750.00 NULL
Federal Unsubsidized Stafford Loan 1000.00 NULL NULL
Federal Unsubsidized Stafford Loan NULL 1000.00 NULL