1
我有以下查詢來爲學生生成財務援助獎勵表。我們希望做一個樞軸,因爲我們想同時爲多個學期提供援助。數據透視表包含額外的行
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
當您剛剛運行select pt。*時會發生什麼?這將顯示你爲什麼得到重複。 – 2013-03-12 19:05:51