Dynamic Crosstab With Store Procedure

Let’s assume that we have table with data like this bellow :

Region

and we want to view data like this

Region2

for that we can write query like this

But, what we can do if the data going bigger and category added, e.g. 1995, 1996. Yes of course we can add

once again but, how if we have many category value which are similary. i think this is a waste, so ot will usefull if we write crosstab dynamicly. let’s check it out

the query above will transform all category value into column, wich distinct will prevent the redundance. just keep in mind and hope this helpfull.