Friday, December 4, 2020

SQL Interview Question - Product Company

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:

SQL:


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.