我有以下几点:
SELECT Custid, Shipperid, Freight
FROM Sales.FreightTotals
UNPIVOT( Freight FOR Shipperid IN([1],[2],[3]) ) AS U;
结果如下:
custid shipperid freight
1 1 25
1 3 100
2 2 75
获取空值后的预期输出:
custid shipperid freight
1 1 25
1 2 NULL
1 3 100
2 1 NULL
2 2 75
2 3 NULL
2条答案
按热度按时间55ooxyrt1#
例如,使用cte将null设为0.00,然后使用nullif()将0.00替换为null:
daupos2t2#
这被认为是
unpivot
. 使用apply
取而代之的是: