日期:2014-05-18 浏览次数:20523 次
declare @sql varchar(8000) select @sql = isnull(@sql + '],[' , '') + exp1 from ( select c.originid + devicecode as exp1 from ChargeOriginByDeviceCode c,Origin o where c.originid = o.originid and o.originname = '艾丽卡' ) a set @sql = '[' + @sql + ']' set @sql = ' select * from ( select date, c.originid + devicecode as exp1, c.price from ChargeOriginByDeviceCode c,Origin o where c.originid = o.originid and o.originname = ''艾丽卡'' ) a pivot ( sum(price) for exp1 in (' + @sql + ')) as t' exec (@sql)