Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need a little help with non aggregate Pivot table

Status
Not open for further replies.

BrooksMT

Programmer
Jun 12, 2013
28
US
This almost works. The SDM_Field contains character data. This should not show all nulls.

Suggestions appreciated.

Thanks,

Brooks

SELECT [DESTFLD]
,[AFS] as AFS,[CLCS] as CLCS,[CPI] as CPI,[ForeignOfficeDeposits] as ForeignOfficeDeposits,[HEQ] as HEQ
,[ILN] as ILN,[INVSEC] as InvSec,[Mansec_Swaps] as Mansec_Swaps,[Manual] as Manualx,[Manual_SBO] as Manual_SBO
,[QRMLiab] as QRMLiab,[TDA] as TDA
FROM
(select [DESTFLD],[SDM_System],[SDM_Field]
from [Reporting].[dbo].[vw_QRM_Transformations_Staging]) ps

pivot
(max( [SDM_field])
for [SDM_System]
in
([AFS],[CLCS],[CPI],[ForeignOfficeDeposits],[HEQ]
,[ILN],[INVSEC] ,[Mansec_Swaps] ,[Manual],[Manual_SBO]
,[QRMLiab],[TDA])
) as pvt

DESTFLD AFS CLCS CPI ForeignOfficeDeposits HEQ ILN InvSec Mansec_Swaps Manualx Manual_SBO QRMLiab TDA
AMORT_DATE NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
AMORT_TYPE NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
AVGBAL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
AVGBALANCE NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
BALLN_DATD NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
BOOK_VALUE NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
 
I figured this out. The DestFld text itself contained square brackets in the text. This messed up the Pivot where square brackets have special meaning.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top