Scenario 1:
Source Table:
Expected Result:
SQL Query: Consider source table as Sample
Using Pivot keyword:
Without using Pivot Keyword:
Scenario 2:
Source:
Expected Result:
Here I am sharing one of the way. If someone come cross better solution you can share it in the comments it will be useful to everyone.