Ordering Results



Hi,

I have a result set that returns Loctation Codes.

Each location code is the following format: [Letter][2 Digit Number].

For example,
A10
B13
D04

What I would like to do is if the letter is either A, C, E, G then order the
results by the letter, then by the 2 digit numbers in ascending order.

If the letter is either B, D, F, H then order the results by the letter,
then by the 2 digit numbers in descending order.

So if A, C, E etc then numbers are ascending.
If B, D, F etc then numbers are descending.

A result set could look as follows
A01
A02
A03
A05
B30
B28
B27
B05
C03
C04
C07
D15
D12
D11

If I could use a case statement within the order by clause, it would solve
my problem, but I get an error when attempting to write a case statement
within the ORDER BY clause.

Thanks in advance,
Wes.
.



Relevant Pages

  • Re: Ordering Results
    ... then by the 2 digit numbers in ascending order. ... then by the 2 digit numbers in descending order. ... If I could use a case statement within the order by clause, ...
    (microsoft.public.sqlserver.mseq)
  • Re: lots of data to be sorted for each unique record
    ... Make sure you sort your data in ascending order by name and descending order by ... john smith 78% ...
    (microsoft.public.excel.misc)
  • Re: need to do a string replace of "asc" to "desc" or "desc" to "asc" first occurrence only
    ... You have an error in your SQL syntax; ... I'll keep looking at it but apparently it chops the ORDER BY clause ... I have a SQL "ORDER BY" clause that will be configured like $orderBy 's ... // it was in descending order ...
    (comp.lang.php)
  • Re: cumulative field
    ... There will be a problem with the SQLECT query if there are two identical ... as the GROUP BY clause will re-order them. ... If your table has a unique key column in ascending order it can by used to ... > How can i perform this by foxpro program, ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Sort Open menu
    ... Arrange Icons By, and in the submenu click Name. ... then menu that is subsequently displayed is sorted in descending order (i.e. ... How can I change it back to ascending order? ...
    (microsoft.public.word.application.errors)