Sql

DeAnna B.

asked • 03/20/23

SQL select if duplicates with max value

Use a SQL statement to find out the names of students whose marks are over 80 in all of their courses


Name course mark

Alice Art 81

Alice Math 74

Ben Art 76

Ben Math 90

Charles Art 81

Charles Math 100

Charles English 90

David L.

tutor
Rize's answer is incorrect. Please see my answer for details.
Report

05/18/23

3 Answers By Expert Tutors

By:

Rize S. answered • 03/23/23

Tutor
New to Wyzant

Master's in MISM, 25 yrs Exp: SQL Specialist

David L.

tutor
Sorry, Rize, your query does not always work. This query works with the data as is. But if you change Alice's marks so that they are all above 80, your query still returns only Charles. That's because the sub-query "SELECT COUNT(DISTINCT course) FROM students" returns 3, which is the number of courses in the table, not the number of courses that Alice actually took.
Report

05/18/23

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.