I have a table Foo with a column ‘FooId‘
The users who choose to have the Foo attribute set, set it with a positive integer while for others the value of this column is -1.
Now, I wish to have the contents of the table ordered by the FooId column such that the results with positive FooId are ordered before the ones that have default value (i.e. -1).
So, I have my query something like select * from Foo order by FooId desc.
Now I want to randomize my results such that results with positive 'FooId' are still before the results with FooId = -1 but the results are ordered randomly. Something with rand() should also be okay, as I am not focusing on performance at the moment.
What are my options to formulate the query?
1 Answer