Skip to content
Advertisement

Query for Exam Score calculation

Problem Statement:

I have an EXAM table which has following fields and sample data

I want to write a SQL query to output the following fields

My SQL Query:

Can I achieve my result by writing a better SQL query?

Advertisement

Answer

You could indeed join the table with several aggregate subqueries that compute the relevant values at student and exam level.

But it seems simpler to use window functions:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement