Been scratching my head on this one, but I feel I'm overlooking the obvious answer, and none of my search phrases have lead to any results.. I am compiling the results of a survey in a database, in the following structure.
ID TestName Q1 Q2 Q3 Q4
-- --------- ---- ---- ---- ----
1 test1 1 2 1 1
2 test1 2 3 4 1
3 test2 1 1 4 2
4 test1 2 5 3 4
5 test2 1 5 2 4
I want to group the similar results in each column, only if they have they share the same Name, and get a count from each similar result. My final output is shown below, but I am trying to find out how to write the query without having 4 separate queries.
Test 1
Question 1 Results
1(1)
2(2)
3(0)
4(0)
5(0)
Question 2 Results
1(0)
2(1)
3(1)
4(0)
5(1)
Question 3 Results
1(1)
2(0)
3(1)
4(1)
5(0)
Question 4 Results
1(2)
2(0)
3(0)
4(1)
5(0)
Test 2
Question 1 Results
1(2)
2(0)
3(0)
4(0)
5(0)
Question 2 Results
1(1)
2(0)
3(0)
4(0)
5(1)
Question 3 Results
1(0)
2(1)
3(0)
4(1)
5(0)
Question 4 Results
1(0)
2(1)
3(0)
4(1)
5(0)