三维表格

 DECLARE @sql VARCHAR(8000)

SET @sql = ''

SELECT  @sql = ISNULL(@sql + ',', '') + QUOTENAME([dates]) + '=max(case when [dates]=' + QUOTENAME([dates], '''') + ' then [subtotal] else 0 end)'

FROM    [V_ALL_Performance]

GROUP BY [dates]

--print @sql

EXEC('select [thisuser]'+@sql+' from [V_ALL_Performance] group by [thisuser]')

 

你可能感兴趣的:(表格)