none
pivot RRS feed

  • 问题

  • 怎么样对pivot结果执行group by 语句,放在什么位置?

    怎么样把这个一下语句改成动态语句。

    SELECT Item AS 项目,
    isnull([1],0) as '1', isnull([2],0) as '2', isnull([3],0) as '3'
    FROM (SELECT * ,MONTH(日期) as month FROM [Sales].[dbo].[SD]) AS SourceTable

    PIVOT(max(金额)FOR month IN ([1], [2], [3]) ) AS PivotTable


    SELECT * ,MONTH(日期) as month FROM [Sales].[dbo].[SD]

    2013年11月21日 6:56

答案

全部回复