0

this is a mysql table

num        wt
a          24
e          22
c          11
d          24
b          13
f          12

how can i create a mysql query which will display with descending order of weights and give random sorting to num with same weight . thus the select query can have two valid results

a    24
d    24
e    22 
b    13
f    12
c    11 

AND

d    24
a    24
e    22 
b    13
f    12
c    11 
silverkid
  • 8,847
  • 20
  • 65
  • 91

1 Answers1

3

Try using

SELECT *
FROM YourTable
ORDER BY wt DESC, RAND()
Adriaan Stander
  • 156,697
  • 29
  • 278
  • 282
  • +1 But is RAND() really required? Doesn't mysql will return the two valid results if run multiple times? – sactiw Oct 30 '15 at 08:28