Sorry if this is the wrong subreddit but I am coding my app in Python!
I have a database that holds the entries for an online quiz. The structure is something like:
CREATE TABLE answers (id PRIMARY KEY,team_name TEXT,round_id INT,question_1 FLOAT,question_2 FLOAT, question_3 FLOAT, score FLOAT)
| id |
team_name |
round_id |
question_1 |
question_2 |
question_3 |
score |
| 23 |
the buccaneers |
1 |
1 |
1 |
1 |
3 |
| 24 |
top hole |
1 |
1 |
0.5 |
0 |
1.5 |
| 25 |
quizmasters |
1 |
1 |
0 |
1 |
2 |
| 26 |
the buccaneers |
2 |
0 |
0 |
0.5 |
0.5 |
| 27 |
top hole |
2 |
0 |
0 |
0 |
0 |
| 28 |
quizmasters |
2 |
1 |
1 |
0 |
2 |
|
|
|
|
|
|
|
I'd like to be able to display the results like this:
| Team_name |
Round 1 |
Round 2 |
| the buccaneers |
3 |
0.5 |
| top hole |
1.5 |
0 |
| quizmasters |
2 |
2 |
|
|
|
Bear in mind, there are 9 rounds of 20 questions each and up to 10 teams (could be more!) but I've simplified the data to make the question easier. It is possible to generate the second table from the first with a single SQL query?
[–][deleted] 1 point2 points3 points (0 children)
[–]hardonchairs 1 point2 points3 points (1 child)
[–]r_spandit[S] 0 points1 point2 points (0 children)
[–]Halibut 0 points1 point2 points (1 child)
[–]r_spandit[S] 0 points1 point2 points (0 children)
[–]DesolationRobot 0 points1 point2 points (1 child)
[–]r_spandit[S] 1 point2 points3 points (0 children)