Calculate the sum of one row and divide by the sum of another row. View / query Oracle

This is my first question here, so bear with me. I have two tables in my Oracle database:

modules with fields:

  • module_codeeg. INF211
  • module_titleeg. Information Technology
  • credits eg.20

module_progress with fields:

  • student_ideg. STU1
  • module_codeeg. INF211
  • module_yeareg. 1
  • module_percenteg. 65

Each student takes 5 modules per year.

So this is what I want to put all of this in a single request / view, if possible:

  • Find the percentage of the module for a specific student
  • Find the sum of all loans for each module in relation to their modules.
  • Divide the percent interest of the module by the amount of loans and multiply by 100 to give me a middle class.

Can this be done?

+5
source share
1
SELECT  student_id,
        SUM(credits * module_percent) / SUM(credits) * 100.0
FROM    module_progress mp
JOIN    modules m
ON      m.module_code = mp.module_code
GROUP BY
        student_id
+1

All Articles