1

I have a table called school where data look like below:

|id|AC|PS|MARKS|
|1 | 1| 1|500  |
|1 | 1| 1|300  |
|1 | 1| 1|10   |
|1 | 1| 1|1    |
|1 | 1| 1|0    |
|1 | 1| 2|300  |
|1 | 1| 2|250  |
|1 | 1| 2|100  |
|1 | 1| 2|50   |
|1 | 2| 1|375  |
|1 | 2| 1|221  |
|1 | 2| 1|122  |

I want to rank based on MARKS within a AC within a PS as below:

|id|AC|PS|MARKS|RANK
|1 | 1| 1|500  |1
|1 | 1| 1|300  |2
|1 | 1| 1|10   |3
|1 | 1| 1|1    |4
|1 | 1| 1|0    |5
|1 | 1| 2|300  |1
|1 | 1| 2|250  |2
|1 | 1| 2|100  |3
|1 | 1| 2|50   |4
|1 | 2| 1|375  |1
|1 | 2| 1|221  |2
|1 | 2| 1|122  |4

I'm fairly new to MySQL and can't figure this out. My table has 1900000 rows. Can someone give me a solution to this?

ProgSnob
  • 483
  • 1
  • 9
  • 20

0 Answers0