2
对不起,以前不清楚的问题;希望我能重新开始......PIVOT未按预期执行
我有这样的数据:
entityid name stringvalue
----------- -------------------- --------------------
1 ShortDescription Coal
1 LongDescription BlackCoal
1 ShortDescription Gold
1 LongDescription WhiteGold
1 ShortDescription Steel
1 LongDescription StainlessSteel
而这个查询:
select *
from
(
select entityid, name, stringvalue as stringvalue
from mytable
) as d
pivot
(
min([stringvalue])
for [name] in ([ShortDescription],[LongDescription])
)
as p
生产这种输出:
entityid ShortDescription LongDescription
-------- ---------------- ---------------
1 Coal BlackCoal
有人能告诉我为什么其他行不在制作中?我期待看到:
entityid ShortDescription LongDescription
-------- ---------------- ---------------
1 Coal BlackCoal
1 Gold WhiteGold
1 Steel StainlessSteel