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

Home -> Community -> Usenet -> c.d.o.server -> Re: "ORDER BY" problems

Re: "ORDER BY" problems

From: Alton Ayers <altona_at_ditw.com>
Date: 1997/07/17
Message-ID: <33CE8ECD.26B9@ditw.com>#1/1

Try this:

SELECT title
FROM work
ORDER BY NVL(sort_title, title);

Roy Smith wrote:
>
> I've got a table containing 2 columns, title, and sort_title, both
> varchar2's. I want to get a sorted list of titles. That's relatively
> straight forward, I can just do "select title from work order by title",
> but there's a hitch.
>
> For most rows, sort_title is null. But, when it's not null, it's a string
> to be used to establish sorting order instead of title. Thus, title might
> be "The Life and Times of Fred Foobar" and sort_title might be "Life and
> Times of Fred Foobar". Is there any way to say "order by (sort_title if
> it's not null, otherwise by title)"?
>
> The quickest way out of my dilema is to just have every row include a
> value for sort_title, regardless of whether it is the same as title or
> not. That would certainly work, but would waste a lot of space. I'm
> hoping to find a better solution.
>
> --
> Roy Smith <roy_at_popmail.med.nyu.edu>
> New York University School of Medicine
> 550 First Avenue, New York, NY 10016
Received on Thu Jul 17 1997 - 00:00:00 CDT

Original text of this message

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