Helpful Information
Category: ORDER BY field
ORDER BY field > value

Is it possible to do something like the following?

SELECT * FROM mod_drivers ORDER BY (driver_quickest > 0.000) ASC

The issue is, I have a table which has a field (driver_quickest) that stores a drivers times. e.g. 5.998

I want to order the table from lowest to higest (quickest to slowest) without including the non entries or yet to be filled in results.

If a field has 0.000 I want it to display after the sorting of the filled in results


Yes, you can order like this. But if you need to sort from lowest to highest with 0 at the end, you would need DESC instead of ASC (since you do not have negative values, 0 would be at the end ).

Thanks, the issue with that is, it would put the highest time at the top while I need the lowest at the top then put the 0.000 results at the bottom.

FOR NOW I have put in a hack, if the result equals 0.000 then make it equal 9.999 which works but isn't the best solution.

Yes, sorry.

I think you could try the following:

SELECT field1
, driver_quickest
, CASE WHEN driver_quickest>0 THEN 0 ELSE 1 END order1
FROM tab1
ORDER BY order1, driver_quickest ASC

Ordering by order1 will move 0's to the end, ordering by driver_quickest will order inside each group (inside the group where order1=0 and inside the group where order1=1).

try this:
ORDER BY -driver_quickest DESCthis works perfectly if you use NULL instead of 0.00

which i suspect you should be doing :)