A challenge for MySQL experts
Good afternoon, I came across a problem that was simple in appearance, but to solve which you need to move your brains well :)
So: we have the following table:
It is necessary to put down a place in the rating of each record, based on points (rating), and if the points coincide, use a secondary attribute (in this case, id). As a result, you need to get the following table:
Important note: the answer must be a single UPDATE query (you can use nested SELECT queries).
Waiting for suggestions :)
So: we have the following table:
id | rating | place |
---|---|---|
1 | 86 | Null |
2 | 5 | Null |
3 | 5 | Null |
4 | 41 | Null |
5 | 1 | Null |
6 | 91 | Null |
It is necessary to put down a place in the rating of each record, based on points (rating), and if the points coincide, use a secondary attribute (in this case, id). As a result, you need to get the following table:
id | rating | place |
---|---|---|
1 | 86 | 5 |
2 | 5 | 2 |
3 | 5 | 3 |
4 | 41 | 4 |
5 | 1 | 1 |
6 | 91 | 6 |
Important note: the answer must be a single UPDATE query (you can use nested SELECT queries).
Waiting for suggestions :)