-1

I am working with a practice SQlite3 table (gradebook) to learn more about them and it is set up with the following 3 columns

gradebook
   * student_id
   * student_name
   * test_score

I am trying to write a command that can help me find the % of students who scored over a certain score (0-100) on an exam and have a certain last name.

I was trying to follow this link,

How to calculate percentage with a SQL statement

but I don't have enough understanding to generalize the equation. Was looking for some guidance?

Kunal Shah
  • 610
  • 6
  • 17

1 Answers1

0

I was able to piece it together. For a score threshold of 75 and last name of Smith:

100.0 / (SELECT COUNT(*) FROM gradebook) * (SELECT COUNT(*) FROM gradebook WHERE test_score > 75 AND student_name LIKE '%Smith%')

Where (SELECT COUNT(*) FROM gradebook) gives the total number of students, and (SELECT COUNT(*) FROM gradebook WHERE test_score > 75 AND student_name LIKE '%Smith%' gives the total number of students who scored above 75 and had the name 'Smith' present.

Kunal Shah
  • 610
  • 6
  • 17