I have table a
Name District Source Revenue
Dave 34 A 120
John 36 B 140
Juyt 38 C 170
And table b
Name District Product Cost
Dave 34 A 50
John 36 B 40
I want a view like so. Desired View below.
Name District Source Revenue A B Total Cost
Dave 34 A 120 50 0 50
John 36 B 140 0 40 40
Juyt 38 C 170 0 0 0
The number of products is not fixed for each lookup in table b. Is there a way to unpivot when you the number of products like Product A, Product B are not fixed. I do not want to do dynamic SQL and a dynamic unpivot. Is there there any other option to get the desired view ?