This is a follow up question from here.
I have some output and was able to add a total column but now I need to use the column to add percentage like this:
| LESSONID RESPONSE COUNT-> | 0 | 1 | 2 | 3 | 4 | N |
---------------------------------------------------------------------------------------
|lesson1 | 1 (20%) | 1 (20%) | 1 (20%) | 1 (20%) | 1 (20%) | 5 |
|lesson2 | 1 (20%) | 1 (20%) | 1 (20%) | 2 (40%) | 0 | 5 |
|lesson3 | 1 (20%) | 1 (20%) | 0 | 3 (60%) | 0 | 5 |
|lesson4 | 0 | 1 (20%) | 4 (80%) | 0 | 0 | 5 |
|lesson5 | 0 | 5 (100%)| 0 | 0 | 0 | 5 |
I have found some help here but can’t get it all to come together.
*Also I am on SQL Server 2005 which is not represented in SQLFiddle
You can format the result of your pivot query as you would do with any other. So, you might concatenate percentage to its respective source. Here is a SQL FIDDLE.