This is just a sample piece to demonstrate how to "denormalize" data.
Really a fun thing to play with and not taken seriously as a practical script for production.
As a matter of fact I am not fund of using "cursors" in large heavily used tables as will largely affect the performance.
What you are referring to is perhaps Matrix / cross-tab / pivot that always requires some sort of a quantifiable / statistical value in the middle which this script does not care about that.
But, by all means, please share with us if you find a PIVOT method that does denormalize 2 or more tables into 1.
This result may also be achieved in SSAS. But WHY? 😉