I have a table with 2 keyed columns. It looks like this
date sym type val
2020.01.02 ABC 100
2020.01.02 ABC a2 200
2020.01.02 ANX 300
2020.01.02 XYZ a3 400
2020.01.02 XYZ a2 100
Note that type
column has some null values. I want to transpose that table to
date sym type_null type_a2 type_a3
2020.01.02 ABC 100 200 0
2020.01.02 ANX 300 0 0
2020.01.02 XYZ 0 100 400
Note how if type
is null, we give it a value of 0. I can do this by
update type_a2:?[type_a2=0n;0;type_a2]
once the table has been transposed. Is there a more elegant way to do this?
Regarding the transpose, I have no idea how to do that. I tried the following but it did not work.
P:asc exec distinct type from myTable;
pvt:exec P#(type!val) by date,sym from myTable;