Processing of millions of records

We have paper-wise marks records of 50000 students in the database table, and the structure is this table is like

Paper idcode| Studentid| Max Marks|Obtained marks

We want to process the result on various conditions like min passing percentage per paper should be 45% else the student will be failed, and store these processed records in a Published result table. The result table will look like

Studentid| Total marks|Total Obtained marks| ResultPorF|

What should be the way to process the result?


Instead, you can map those to any Query/Script Reports to find any attribute