View Full Version : Custom Order By?


terbs
10-17-2007, 10:43 PM
Wondering if it is possible to order by particular values??

That is I have a column (varchar) named "Status" with values such as; Entered, Active, Completed etc (I didnt design the DB).

What I need is to order by Entered, then by Active then Completed etc.. Is this possible??

Ive got this code for SQL; but it doesnt work in Access (03)..


ORDER BY

CASE Status

WHEN 'Entered' THEN 0

WHEN 'Active' THEN 1

WHEN 'Completed' THEN 2

ELSE 3 END, Status

EMP
10-18-2007, 12:34 AM
SELECT .............
FROM ..........
WHERE ...........
ORDER BY IIf([Status]="Entered", 0, IIf([Status]="Active", 1, 2))

^

terbs
10-18-2007, 03:36 PM
thank you EMP, excatly what I needed!