displaying a record at the end of the query??
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: displaying a record at the end of the query??

  1. #1
    Join Date
    Mar 2001
    Location
    New York , New York
    Posts
    577
    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

  2. #2
    Join Date
    Jan 2001
    Posts
    3,131
    What other columns are in the table, can you do a desc on it?

    MH
    I remember when this place was cool.

  3. #3
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    Do you have a field that indicates when the record was entered?
    Jeff Hunter
    marist89@yahoo.com
    http://marist89.blogspot.com/
    Get Firefox!
    "I pledge to stop eating sharks fin soup and will not do so under any circumstances."

  4. #4
    Join Date
    Mar 2001
    Location
    New York , New York
    Posts
    577
    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

  5. #5
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    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
    marist89@yahoo.com
    http://marist89.blogspot.com/
    Get Firefox!
    "I pledge to stop eating sharks fin soup and will not do so under any circumstances."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width