By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,466 Members | 2,482 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,466 IT Pros & Developers. It's quick & easy.

Special Sort order, 1 , 3 , 2

TheSmileyCoder
Expert Mod 100+
P: 2,321
I have a query in which I would like the items to be returned in a certain order, starting with those having value:
ID_ObservationType=1 and then 3 and then 2.

I used to order it 1,2,3 but now the client has asked for them items to come in a different fashion. Is there a simple way to request this via SQL, so I don't have to write some fancy to solve it.
Mar 3 '10 #1

✓ answered by Delerna

On second thougts, simpler would be

NewSort:iif(ID_ObservationType=2,20,ID_Observation Type)

Share this Question
Share on Google+
3 Replies


Delerna
Expert 100+
P: 1,134
As a "Quick Fix" you could try adding a calculated field to the query

NewSort:iif(ID_ObservationType=1,1,iif(ID_Observat ionType=3,2,3))

and then sorting by that instead
Something along those lines

There is always someone who mucks up your carefully planned database :)
Mar 3 '10 #2

Delerna
Expert 100+
P: 1,134
On second thougts, simpler would be

NewSort:iif(ID_ObservationType=2,20,ID_Observation Type)
Mar 3 '10 #3

TheSmileyCoder
Expert Mod 100+
P: 2,321
Is IIF native SQL (I dont think it is). I would prefer to keep it in native sql if possible, for performance issues. But for now, I will go with your solution Delerna, thank you!
Mar 3 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.