-
Hi,
I am querying a table with country names in it.
I want to display the records in the order they were entered with an exception of one.
For example the records were entered in the order
1. India
2. Australia
3. USA
4. Mexico
5.Brazil
My query should return the names in the following order
India
Australia
Mexico
Brazil
USA
Note that USA is displayed at the end of the result set rather than in the order it was entered and all other records are displayed in the order they were entered.
Please suggest how to do this.
Thanks
Ronnie
-
What other columns are in the table, can you do a desc on it?
MH
I remember when this place was cool.
-
Do you have a field that indicates when the record was entered?
Jeff Hunter
-
Country name is the only column in the table called country.
No there is nothing which tells when the record was entered.
Actually I would say I want to display the countries in the order they are stored in the table with the exception of one that is USA.
Thanks
Ronnie
-
The records are not really stored in any order, per se.
Basically, you could use a decode statement to kind of do what you want:
Code:
select country_name
from countries
order by decode(country_name,'USA',2,1)
Jeff Hunter
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|