我有數據格式如下在TSQL與Sum函數樞軸
Client Business Unit Year Quarter USD Amt
BalckRock Pricing 2010 Q1 234
BalckRock Pricing 2010 Q2 343
BalckRock Pricing 2010 Q3 545
BalckRock Pricing 2010 Q4 5435
BalckRock Pricing 2011 Q1 5425
BalckRock Pricing 2011 Q2 3524
BalckRock Pricing 2011 Q3 54
BalckRock Pricing 2011 Q4 5425
BalckRock Pricing 2012 Q1 545
BalckRock Pricing 2012 Q2 5445
BalckRock Pricing 2012 Q3 545
BalckRock Pricing 2012 Q4 4545
BalckRock Sales 2010 Q1 23
BalckRock Sales 2010 Q2 3434
BalckRock Sales 2010 Q3 4234
BalckRock Sales 2010 Q4 4234
BalckRock Sales 2011 Q1 3423
BalckRock Sales 2011 Q2 1
BalckRock Sales 2011 Q3 1341
BalckRock Sales 2011 Q4 434
BalckRock Sales 2012 Q1 421
BalckRock Sales 2012 Q2 42
BalckRock Sales 2012 Q3 434
BalckRock Sales 2012 Q4 4214
而且我想在下面的格式
Client Business Unit 2010 2011 2012
BalckRock Pricing 6557 14428 11080
BalckRock Sales 11925 5199 5111
基本上USD amnt全年總和明智的,但年列標題
任何人都可以幫助我嗎?
發佈你現有的sql代碼,你有什麼試過? – 2012-07-05 16:27:30
檢查這個問題的代碼 - http://stackoverflow.com/questions/1122117/sql-dynamic-pivot-how-to-order-columns?rq=1 – 2012-07-05 16:29:45