Top performing students by major

Question

You’re given the table below showing a list of students, their GPA, and their associated majors:

Table: student_info

student_id gpa major
57510 3.86 Engineering
57509 3.2 Business
57508 3.9 Engineering
57507 3.45 Engineering
57506 3.26 Business
57505 3.99 Engineering
57504 3.43 Business
57503 3.7 Engineering
57501 3.51 Business
57500 3.97 Engineering
57499 3.43 Business
57498 3.62 Business
57497 3.31 Engineering

Using the table, write a SQL query to return the 3 students with highest GPAs in each major (keeping any ties).

You can view/query this table in an interactive SQL fiddle here.

Solution

Access restricted

Subscribe to premium account to see the solution.

Get premium now