SELECT ClientNo,isnull([1],0) [0-30],isnull([2],0) [31-60],isnull([3],0) [61-90],isnull([4],0) [>90],BrokerName,AsOfDate,UserName
From (Select Amount,ClientNo,DaysInGroup,BrokerName,AsOfDate,UserName FROM #tblPivot) a
PIVOT( sum(Amount)
FOR DaysInGroup IN ([1],[2],[3],[4])) AS PVTTable1
Ex:
Amount ClientNo DaysInGroup BrokerName AsOfDate UserName
16288.333 2 2 GUARDIAN INSURANCE BROKERS 2016-09-10 00:00:00.000 amtpl
479850.254 2 3 GUARDIAN INSURANCE BROKERS 2016-09-10 00:00:00.000 amtpl
Ans:
ClientNo 0-30 31-60 61-90 >90 BrokerName AsOfDate UserName
2 0.00 16288.333 479850.254 0.00 GUARDIAN INSURANCE BROKERS 2016-09-10 00:00:00.000 amtpl
From (Select Amount,ClientNo,DaysInGroup,BrokerName,AsOfDate,UserName FROM #tblPivot) a
PIVOT( sum(Amount)
FOR DaysInGroup IN ([1],[2],[3],[4])) AS PVTTable1
Ex:
Amount ClientNo DaysInGroup BrokerName AsOfDate UserName
16288.333 2 2 GUARDIAN INSURANCE BROKERS 2016-09-10 00:00:00.000 amtpl
479850.254 2 3 GUARDIAN INSURANCE BROKERS 2016-09-10 00:00:00.000 amtpl
Ans:
ClientNo 0-30 31-60 61-90 >90 BrokerName AsOfDate UserName
2 0.00 16288.333 479850.254 0.00 GUARDIAN INSURANCE BROKERS 2016-09-10 00:00:00.000 amtpl
No comments:
Post a Comment