Re: Nested sort, trying again

From: vc <>
Date: 30 Sep 2005 05:03:49 -0700
Message-ID: <>

Bob Stearns wrote:
> In this case the tree is sorted in the order I want to present it to my
> users. Consider the tree z(y(x,w),v(y(t,s))) which would have a similar
> representation to the first on but which I wish to present to my users as:
> z
> v
> u
> s
> t
> y
> w
> x
> The question is: Is there an easy (relatively) way to produce this sort
> without a recursive sql user defined function?

No, you cannot do that in the standard SQL even resorting to tricks like nested intervals or some such. What you want to do is the a DFS(depth-first search) with siblings ordered by their names.

Oracle's proprietary 'connect by' will do that easily with the usual (child, parent) representation. DB2's recursive query however won't because it performs a BFS (breadth-first search. Received on Fri Sep 30 2005 - 14:03:49 CEST

Original text of this message