jeudi 26 mars 2015

Order field values in round-robin in MySQL


I have table like this:



id order_number
1 20
2 20
3 20
4 21
5 21
6 21
7 21
8 21
9 21
10 22
11 23
12 23
13 24


I need to arrange the rows such that the order_numbers are arranged round-robin sequence (20,21,22,23,24 then again 20,21,22,23,24 and again 20 etc..), i.e.



id order_number
1 20
4 21
10 22
11 23
13 24
2 20
5 21
12 23
3 20
6 21
7 21
8 21
9 21


Does anyone know how to write the query for this? Thanks in advance!





Aucun commentaire:

Enregistrer un commentaire