日期:2014-05-19 浏览次数:20641 次
Select YEAR(createDate), MAX(Case MONTH(createDate) When 1 Then surrogateSum Else 0 End) S1, -- 1月代理费 MAX(Case MONTH(createDate) When 1 Then amount Else 0 End) A1, -- 1月总额 MAX(Case MONTH(createDate) When 2 Then surrogateSum Else 0 End) S2, -- 2月代理费 MAX(Case MONTH(createDate) When 2 Then amount Else 0 End) A2, -- 2月总额 MAX(Case MONTH(createDate) When 3 Then surrogateSum Else 0 End) S3, -- 3月代理费 MAX(Case MONTH(createDate) When 3 Then amount Else 0 End) A3, -- 3月总额 ... From AccountTable Group By YEAR(createDate)