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
  • 9,291
  • 22
  • 66
  • 92

1 Answers1

3

Try using

SELECT *
FROM YourTable
ORDER BY wt DESC, RAND()
Adriaan Stander
  • 162,879
  • 31
  • 289
  • 284
  • +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