How to create pivot using sql
问题 I am new to SQL, I have a table like this. Below is the query : select gc.GC_Name, dt.GC_SectorType, dt.ageing, sum(cast(dt.[Brokerage Debtors] as numeric)) as Brokerage_Amt, dt.divisionalofficename from [AR].[Fact_Brokerage_Debt] dt inner join AUM.DIM_BUSINESS_TYPE BT on BT.Business_Type_WId_PK = dt.BusinessType_WID inner join aum.Dim_GroupCompany gc on dt.insurer_Wid = gc.GC_WID where bt.Business_Type_Wid in (4, 8, 10) and dt.ageing <> '<30' and cast(dt.[Brokerage Debtors] as numeric) > 0