Re: Slighty OT - ORDER BY query -
06-01-2004
, 10:59 AM
Need a little more info. But you said you wanted to display all ENHANCED
listings at the top of the page in random order, then all NAME listings in
alphabetical order. This leads me to believe ENHANCED is some sort of boolean
field.
Try
ORDER BY CASE WHEN ENHANCED=1 THEN rand() ELSE NAME END
This assumes ENHANCED is an integer or bit field. You may have to change the
condition.
But basically, if a record is ENHANCED, then it's ordered by a random number.
If it's not, it's ordered by its name. This will only work if a name will
never start with a digit, e.g., if a one of the records has the name "5-Iron",
then it will probably show up somewhere within the ENHANCED listings.
Hope this can get you started. |