Link to home
Start Free TrialLog in
Avatar of Fordraiders
FordraidersFlag for United States of America

asked on

Order By specific order

Access 2010

Is there a way to tell a query to do an order by in a specifc order ?


SELECT WwgCore.ITEM, WwgCore.SPIN
FROM WwgCore
WHERE (((WwgCore.SPIN)="ST" Or (WwgCore.SPIN)="TP" Or (WwgCore.SPIN)="LS" Or (WwgCore.SPIN)="C3" Or (WwgCore.SPIN)="C4"))
ORDER BY WwgCore.SPIN;

But I want it To return in this order specifically

ST
TP
LS
C3
C4

Thanks
fordraiders
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No points please.  Either of the methods above will work, but method one is not very flexible( you must change the sort order in the query if you add a [SPIN] value to the query.

I prefer the method provide by peter, although this can result in a bunch of additional tables, if you want to do this for different stuff.  The other advantage of this method is that you can create a form that allows you to change the sort order within the application.
Avatar of Fordraiders

ASKER

Thanks fyed for additional comments. I like them both.