Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: How to display the return this way?
C Chang <cschang_at_maxinter.net> wrote in message news:<3C1A1F19.1421_at_maxinter.net>...
> I have a select script such as:
>
> Select A, B
> from myTable
> where A = 'A1'
> or A = 'D1'
> or A = 'C1'
> or A = 'B1';
>
> How do I let my return display as my order in where clause:
>
> A1 Bxx
> D1 BXXX
> C1 BX
> B1 Byy
>
> but not in sorted order of column A -> A1, B1, C1, D1.
>
> C Chang
There is probably a better answer, but I can think of two possibilities at present:
First, you could write a function to order your data by rules that you determine and call it in an order by clause
or
you could try unioning a series of queries for one value at a time together
select A, B from mytable where A = 'A1'
union all
select A, B from mytable where A = 'D1'
union all
....
Normally you either get the data back in the order that Oracle's access path logic left it in or you specify the desired order using an order by clause.