Skip to content
Advertisement

Oracle SQL to calculate percentage

I’m trying to calculate the percentage based on the total students for each subject and by grade distribution.

I have table with the following fields:

  • Student Id
  • Term,
  • Course
  • final grade

Sample Data

I wrote the below query to get the total per course and per grade

I cannot use the below code because it will calculate the overall total and not per subject :

the output should be similar to the below

Output required

please help

thank you

Advertisement

Answer

If I understand correctly, you want aggregation with a window function to calculate the total for the subject:

SqlFiddle

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