我有一个类似于下面显示的数据库的学生考试数据数据库。我试图通过对一个学期( )的所有科目( )ranks
的总和并相应地对它们进行排序来分配这些学生。Marks
Subj
Sem
因此,如果这是原始数据库:
Name | S.NO.| Subj | Sem | Marks | Rank
ab | B1 | C1 | 1 | 002 |
ab | B1 | C2 | 1 | 004 |
ab | B1 | C3 | 1 | 005 |
ab | B1 | C4 | 2 | 008 |
xy | C2 | C1 | 1 | 006 |
xy | C2 | C2 | 1 | 004 |
xy | C2 | C3 | 2 | 007 |
xy | C2 | C4 | 2 | 009 |
xy | C2 | C5 | 2 | 003 |
sm | Z1 | C1 | 1 | 006 |
sm | Z1 | C2 | 2 | 004 |
sm | Z1 | C3 | 2 | 008 |
我想将其转换为:
Name | S.NO.| Subj | Sem | Marks | Rank
ab | B1 | C1 | 1 | 002 | 1(coz his total is 11 in sem 1)
ab | B1 | C2 | 1 | 004 | 1
ab | B1 | C3 | 1 | 005 | 1
ab | B1 | C4 | 2 | 008 | 3
xy | C2 | C1 | 1 | 006 | 2
xy | C2 | C2 | 1 | 004 | 2
xy | C2 | C3 | 2 | 007 | 1(coz his total is 19 in Sem 2)
xy | C2 | C4 | 2 | 009 | 1
xy | C2 | C5 | 2 | 003 | 1
sm | Z1 | C1 | 1 | 006 | 3
sm | Z1 | C2 | 2 | 004 | 2
sm | Z1 | C3 | 2 | 008 | 2
该数据库有大约 300k 行。