I'm able to unpivot a table but null values are not included in the result.
create table pivot_task
(
age int null,
[a] numeric(8,2),
[b] numeric(8,2),
[c] numeric(8,2),
[d] numeric(8,2),
[e] numeric(8,2)
);
select * from pivot_task;
insert into pivot_task values (18, 0.5, null, 0.6, 1.21, 1.52),
(19, 7.51, 6.51, 5.51, null, 3.53),
(20, 4.52, 4.52, 6.52, 3.53, null);
select age, [over], [av]
from pivot_task
unpivot
(
[av]
for [over] in ([a], [b], [c], [d], [e])
) a;
You can see the result on http://sqlfiddle.com/#!6/2ab59/1 for 18 age [over] b and its null value is missing I want to include null as well for every null encounter.
I found replacing null with different value and then replacing all those constant different value approach is not feasible for my work. I want to include in unpivot only.