Here is the situation I'm trying to solve:
I have a query that can return a recordset. A field that is sorted can have several different values ββ- for this question we will say that this value can be A, B, C, D, E or Z
Now, depending on the results of the query, sorting should behave as follows: If only AE records are found, sorting them is "naturally" in order. But if there is a Z record in the results, then this should be the first result in the query, but the rest of the records should be in the "natural" sort order.
For example, if an ACD is found, then the result should be
A C D
But if ABDEZ is found, the result should be sorted:
Z A B D E
Currently, the request looks like this:
SELECT NAME, SOME_OTHER_FIELDS FROM TABLE ORDER BY NAME
I know that I can code the sort function to do what I want, but due to the way I use the results, I cannot use it because the results are processed by a third-party library, to which I am just passing the SQL query. Then it processes the results, and there seems to be no binding for sorting the results and just passing the results to the library. He must execute the SQL query himself, and I do not have access to the source code of the library.
So, for all of you SQL gurus, can you provide a query for me that will do what I want?
Zeke hansell
source share