Help me please!! Then you can use COUNT with GROUP BY to show the number of students with each of those grades.
Now, this step is a little tricky. The goal is a table that shows how many students have earned which letter_grade
. You can output the letter_grade
by using CASE
with the number_grade
column, outputting 'A' for grades > 90, 'B' for grades > 80, 'C' for grades > 70, and 'F' otherwise. Then you can use COUNT
with GROUP BY
to show the number of students with each of those grades.
My code is next:
CREATE TABLE student_grades (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
number_grade INTEGER,
fraction_completed REAL);
INSERT INTO student_grades (name, number_grade, fraction_completed)
VALUES ("Winston", 90, 0.806);
INSERT INTO student_grades (name, number_grade, fraction_completed)
VALUES ("Winnefer", 95, 0.901);
INSERT INTO student_grades (name, number_grade, fraction_completed)
VALUES ("Winsteen", 85, 0.906);
INSERT INTO student_grades (name, number_grade, fraction_completed)
VALUES ("Wincifer", 66, 0.7054);
INSERT INTO student_grades (name, number_grade, fraction_completed)
VALUES ("Winster", 76, 0.5013);
INSERT INTO student_grades (name, number_grade, fraction_completed)
VALUES ("Winstonia", 82, 0.9045);
SELECT name, number_grade, Round(fraction_completed*100)as percent_completed from student_grades ;
SELECT name, number_grade,
CASE
WHEN number_grade>90 THEN "A"
WHEN number_grade>80 THEN "B"
WHEN number_grade>70 THEN "C"
ELSE "F"
END as "letter_grade"
FROM student_grades;
SELECT number_grade, COUNT (*)
FROM student_grades
Group by number_grade
======================================
I know that it should be letter_grade (not number_grade) on the last 3 lines but the program say, that it is NO such a ROW.
Please sign in to leave a comment.