This could be done with [`rank()`](https://www.postgresql.org/docs/current/static/tutorial-window.html).
This could be done with
rank().