I have the following table:
id type result
--- --- ------
1 a 39
1 b 412
2 a 42
3 a 32
3 b 390
Now I would like to add rankings to this table for the result dependent on the type, so every type should have a single ranking ascending according to the value in the column result (and there are around 20 different types in the original table).
The result should be like this:
id type result rank
-- --- ------ ----
1 a 39 2
1 b 412 2
2 a 42 3
3 a 32 1
3 b 390 1
I found several solutions to add rankings to tables here, but how can I create rankings taking account the value of another column?