Muflix Asked: 2014-11-17 01:31:57 +0800 CST2014-11-17 01:31:57 +0800 CST 2014-11-17 01:31:57 +0800 CST 列成行,行成列 772 我需要做这个表格转换,但对我来说有点难。 我有原来的桌子,看起来像这样 我需要把桌子变成这个 我怎样才能做到这一点 ? 在这里我准备了示例数据库http://sqlfiddle.com/#!3/0f324 感谢您的帮助。 sql-server sql-server-2008-r2 1 个回答 Voted Best Answer abianari 2014-11-17T03:49:22+08:002014-11-17T03:49:22+08:00 select * from ( select SubBrand,Month,Saless,Variable from (select * from DataTable )as p unpivot (Saless for Month in(January,February)) as u ) as p pivot ( min(Saless) for Variable in ([Sales],[Promotion]) )as PP order by SubBrand,Month
1 个回答