In: Computer Science
In addition to calculating and outputting each students quiz grade to calculate the average score for each quiz and the average of all the student quiz averages. Output the results at the bottom of each quiz column and the Quiz Average column (Row 22).
Hint: Be careful when setting up your expression to calculate the average of all the quiz averages, this may require a slightly different expression then the others (not due to math).
Student | Quiz 1 | Quiz 2 | Quiz 3 | Quiz 4 | Quiz 5 | Quiz Average |
Jimmy | 78 | 82 | 83 | 66 | 79 | |
Elsa | 87 | 72 | 83 | 70 | 100 | |
Robert | 95 | 96 | 100 | 81 | 74 | |
Dave | 62 | 99 | 94 | 65 | 69 | |
Jenna | 70 | 68 | 87 | 63 | 88 | |
Liza | 100 | 88 | 84 | 60 | 66 | |
Pete | 91 | 87 | 72 | 70 | 65 | |
Fred | 75 | 86 | 82 | 61 | 81 | |
Wilma | 96 | 85 | 92 | 64 | 67 | |
Betty | 60 | 86 | 68 | 90 | 72 | |
Barnie | 84 | 72 | 97 | 64 | 98 | |
Jonas | 80 | 85 | 89 | 96 | 78 | |
Hank | 77 | 62 | 78 | 61 | 78 | |
Archie | 84 | 98 | 70 | 72 | 97 | |
Veronica | 74 | 83 | 96 | 88 | 75 | |
Marge | 60 | 84 | 99 | 82 | 90 | |
Homer | 97 | 90 | 84 | 69 | 81 | |
Bart | 82 | 100 | 65 | 85 | 98 | |
Lisa | 95 | 93 | 73 | 90 | 62 | |
Reginald | 64 | 77 | 62 | 85 | 100 |
Syntax for creating table
create table Quiz(Student varchar(30),Quiz1 int, Quiz2 int, Quiz3 int,Quiz4 int, Quiz5 int, Quiz_Average float);
Syntax for inserting data
insert into Quiz values('Elsa',87,72,83,70,100,NULL), ('Robert',95,96,100,81,74,NULL), ('Dave',62,99,94,65,69,NULL), ('Jenna',70,68,87,63,88,NULL), ('Liza',100,88,84,60,66,NULL), ('Pete',91,87,72,70,65,NULL), ('Fred',75,86,82,61,81,NULL), ('Wilma',96,85,92,64,67,NULL), ('Betty',60,86,82,61,81,NULL), ('Barnie',84,72,97,64,67,NULL), ('Jonas',80,85,89,96,78,NULL), ('Hank',77,62,78,61,78,NULL), ('Archie',84,98,70,72,97,NULL), ('Veronica',74,83,96,88,75,NULL), ('Marge',60,84,99,82,90,NULL), ('Homer',97,90,84,69,81,NULL), ('Bart',82,100,65,85,98,NULL), ('Lisa',95,93,73,90,62,NULL), ('Reginald',64,77,62,85,100,NULL), ('Average_Score',NULL,NULL,NULL,NULL,NULL,NULL);
Syntax for Finding and updating the Quiz Average
update Quiz set Quiz_Average = (Quiz1+Quiz2+Quiz3+Quiz4+Quiz5)/5 where Student = 'Elsa';
here at place of Student column you have to change the name of student so you can able to find out the auiz average of everyone and update the value of it.
Expression for finding the Quiz Average
Quiz_Average = (Quiz1+Quiz2+Quiz3+Quiz4+Quiz5)/5
Syntax for finding and updating the Average Score
update Quiz set Quiz1 = ( select sum(Quiz1) from Quiz)/20 where Student = 'Average_Score';
here you have to change the Quiz column name so you can update the value of Average_Score
Expression for finding the Average Score
Average score = (select sum(Quiz1) from Quiz)/20
Here is the Output