Custom Order By?

terbs

Registered User.
Local time
Tomorrow, 07:49
Joined
May 15, 2007
Messages
38
[Resolved] Custom Order By?

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)..

Code:
ORDER BY 

 CASE Status

  WHEN 'Entered' THEN 0

  WHEN 'Active' THEN 1

  WHEN 'Completed' THEN 2

  ELSE 3 END, Status
 
Last edited:
SELECT .............
FROM ..........
WHERE ...........
ORDER BY IIf([Status]="Entered", 0, IIf([Status]="Active", 1, 2))

^
 
thank you EMP, excatly what I needed!
 

Users who are viewing this thread

Back
Top Bottom