1
Answer

UNPIVOT with NULL values

Martin James

Martin James

3y
628
1
I have the following query : 
  1. SELECT Custid, Shipperid, Freight  
  2. FROM Sales.FreightTotals  
  3. UNPIVOT( Freight FOR Shipperid IN([1],[2],[3]) ) AS U;  
I have the following result :
 
custid    shipperid    freight
1              1              98
1              3              55
2              2              75
 
This is my expected output :
 
custid    shipperid    freight
1              1              98
1              2              NULL
1              3              55
2              1              NULL
2              2              75
2              3              NULL
Answers (1)