日期:2014-05-16 浏览次数:20437 次
DECLARE @sql NVARCHAR(MAX)
SELECT @sql = ISNULL(@sql , '') + N' max(case when paychannel_name = ''' + a.pNaychannel_name + N''' then price else 0 end) as ' + a.paychannel_name + N'支付 ,'
+ N' max(case when paychannel_name) = ''' + a.paychannel_name + ''' then userorder_sucess_user else 0 end) as ' + a.paychannel_name + N'成功人数 ,'
from (SELECT DISTINCT paychannel_name FROM t1) AS a
SET @sql = N'select dateid , ' + LEFT(@sql , LEN(@sql) - 1) + N' from t1 group by dateid'
EXEC @sql