If I understand correctly, I think that you need to constantly organize the result set every time, you can use something like order_by('score','id') , which will order first by account first, and then auto-increment id in score with the same values, therefore, your result is consistent. The documentation is here . You must be explicit in order_by if you want to get the correct set of results every time using "id" is one way.
source share