jeudi 15 mars 2018

Mysql-> Group after rand()

I have the following table in Mysql

Name  Age   Group


 abel    7      A
 joe     6      A
 Rick    7      A
 Diana   5      B
 Billy   6      B
 Pat     5      B

I want to randomize the rows, but they should still remain grouped by the Group column. For exmaple i want my result to look something like this.

 Name  Age   Group


 joe     6      A
 abel    7      A
 Rick    7      A
 Billy   6      B
 Pat     5      B
 Diana   5      B

What query should i use to get this result? The entire table should be randomised and then grouped by "Group" column.




Aucun commentaire:

Enregistrer un commentaire