Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using ORDER BY DECODE in Access

Status
Not open for further replies.

monika102001

Programmer
Sep 25, 2005
26
US
Is anybody knows if Access has something like Oracle using in SQL 'Order By Decode..'.
What I need to do is order records the way I want not ASC or DESC.I want first with the value 1 then 3 then 2.

Thanks
 
I've never heard of such a thing in Access. I think if I had that requirement I would create a seperate Decodes table, with one field for the Decode values, the other with the SortOrder number. You could then join the original table to the Decodes table (by the Decode field), and sort by the Decode table's SortOrder field.
 
Or add a calculated field to your query along the lines of:

Ordinal: [FieldName] Mod 2

Then sort by the calculated field ascending first, then the field itself ascending... this approach will put the numbers 1, 2 and 3 into the order 1, 3, 2.

[pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top