Skip to content
Advertisement

How we can loop over SQL Column with specific condition

Explanations:

  1. In 1st picture data we have.
  2. In the 2nd picture report we want to generate using SQL.
  3. In the last we have added table and data script

We have SQL Data in this format.

We want Report Like this

  1. Column Calculation = 2(Yes)/3(Total Column Contain Yes/NO) *100

Sample data:

Advertisement

Answer

You need to unpivot the CL values first and then implement a dynamic pivot:

Results:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement