Skip to the content

Two exams, added up wrong

Problem

Rose went back over her exams and thinks she added up two of them wrong: Lucas's in Math and Megan's in Science. grades has no names, only numbers. Lucas is student 1 and Megan is student 5; Math is course 1 and Science is course 3.

Show the two rows of grades that Rose is going to check, with student_id, course_id, and grade, in that order. It's those two and no others: if tomorrow Lucas has a grade in Science or Megan has one in Math, those exams were added up fine and stay out.

What it has to return

These rows, in any order

student_idcourse_idgrade
118.5
538.5

This is what comes out with the data in the practice database this challenge uses. The column names don’t count, so name yours however you like: what counts is how many there are and the order they come in. Besides this one, the challenge has hidden tests with other data that are revealed when you submit your solution.

You start with this

SQL

SELECT student_id, course_id,
  grade
FROM grades
WHERE student_id = 1
Solve this challenge

It opens in your browser, with the editor and the tests. It is free and you do not need an account to start.

More O(1) challenges

See all challenges →