Re: Nested sort, trying again

From: vc <boston103_at_hotmail.com>
Date: 30 Sep 2005 05:03:49 -0700
Message-ID: <1128081829.713366.235200_at_g47g2000cwa.googlegroups.com>


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