Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: Start with some, order by others?

Re: Start with some, order by others?

From: Marc Billiet <someone.overthere_at_living>
Date: Fri, 15 Sep 2000 05:27:03 GMT
Message-ID: <20000915.5270308@slu4508f.hae.hydro.com>

You can do something like:

select name, country id
from countries
order by decode(name,'United States', '@', 'Canada', '@@', name)

But it might be better to add a column to your table (let's call it 'priority' in the following example):

alter table countries add (priority number);

update countries
set priority = 1
where name = 'United States';

update countries
set priority = 2
where name = 'Canada';

select name, country id
from countries
order by priority, name;

or (if you didn't execute the update):

select name, country id
from countries
order by nvl(priority, 99), name;

Marc

>>>>>>>>>>>>>>>>>> Oorspronkelijk bericht <<<<<<<<<<<<<<<<<<

Op 2000-09-14, 23:31:12, schreef David Fetter <shackle_at_fetter.org> over het
thema Start with some, order by others?:

> Kind people,
 

> I have a list of countries I'd like to present. Given the givens, I'd
 

> like to start with certain countries, then the others in alphabetical
 

> order.
 

> What I'd like back:

> NAME COUNTRY ID
> --------------------------------------------------------------
> United States 840
> Canada 124
> Afghanistan 4
> Albania 8
> Algeria 12
> .
> .
> .
> Zimbabwe 716

> How do I do this?
 

> TIA for any tips, pointers, etc.
 

> Cheers,
> D
> --
> David Fetter 888 O'Farrell Street Apt E1205
> david_at_fetter.org San Francisco, CA 94109-9046
> http://fetter.org/~shackle phone: +1 415 567 2690 fax: +1 415 567 2340

> I don't know what's wrong with my television set. I was getting
> C-Span and the Home Shopping Network on the same station. I actually
> bought a congressman.
> Bruce Baum
Received on Fri Sep 15 2000 - 00:27:03 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US