473,383 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Special Sort order, 1 , 3 , 2

TheSmileyCoder
2,322 Expert Mod 2GB
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)

3 1792
Delerna
1,134 Expert 1GB
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
1,134 Expert 1GB
On second thougts, simpler would be

NewSort:iif(ID_ObservationType=2,20,ID_Observation Type)
Mar 3 '10 #3
TheSmileyCoder
2,322 Expert Mod 2GB
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

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

Similar topics

4
by: its me | last post by:
Let's say I have a class of people... Public Class People Public Sex as String Public Age as int Public Name as string end class And I declare an array of this class...
20
by: Xah Lee | last post by:
Sort a List Xah Lee, 200510 In this page, we show how to sort a list in Python & Perl and also discuss some math of sort. To sort a list in Python, use the “sort” method. For example: ...
7
by: Steve Crawford | last post by:
I am suffering some sort order confusion. Given a database, "foo", with a single character(4) column of data left padded with spaces I get: select * from foo order by somechars; somechars...
2
by: adrian.chandler | last post by:
Hi all, I have been using letter and symbol codes such as GNU< GNU\ GNU} GNU in an Access table. I was surprised to see that when the table was sorted on this field, the order is: GNU...
5
by: Jan Smith | last post by:
I've searched the overloads for the Array.Sort method, and I haven't found a clear answer to my question. Maybe it's not in Array.Sort. Here's the question: I initialize an array X with the...
2
by: Patrick | last post by:
I got a page that loads a xml file into a treeview control. I want it to sort the data before sending it to the treeview control is that possible? <root> <level1 name="" src="" order="0">...
6
by: weetat.yeo | last post by:
Hi all , I have sql statement below , SELECT serial_no,host_name,chasis_model,chasis_flash_size,chasis_dram_size,...
4
by: wheel | last post by:
I have already built in support for multiple languages in some of my applications, but so far they have only used Western languages (English, Spanish, etc). I need to add some Far East languages:...
6
by: Kc-Mass | last post by:
In a standard Ascii table a dash or hyphen is decimal 45. A period or dot is decimal 46. If I sort a table or recordset of mixed character string ascending in Access, those strings beginning with...
3
KevinADC
by: KevinADC | last post by:
Purpose The purpose of this article is to discuss the difference between characters inside a character class and outside a character class and some special characters inside a character class....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.