Hierarchical data and sorting
Date: Tue, 22 Jun 2004 12:28:02 +0200
Message-ID: <40d809b2$0$28580$a0ced6e1_at_news.skynet.be>
Hi there !
First of all, I hope I am posting in the right forum. Otherwise, please excuse me !
I am trying to organize a table in a hierarchical way. I think I will use a preordered tree traversal to do this.
The problem is :
My aim is to display the data with indenteation AND with sorting, but with
sorting only on the parents.
Let me explain this. Most of the data is on the same level, ie :
|
|-data1
|-data2
|-data3
| |-data4
|-data5
|-data6
...
I run a query (kind of complex, with lots of joins a lots of returned
fields) that can return any level of data. The result of this query can be
sorted in any order according to the user's preferences.
What I would like to do is to sort the data ONLY on the parent if there is
one in the result set.
For instance, a query could return something like :
data1
data6
data3
data4
data2
Or
data1
data4
data6
But NOT
data1
data4
data6
data3
(because the parent AND the child are present, so the child must be under
its parent)
Does anyone know of an easy (hum.... well no too complex) way of doing this
?
As I said before, the query is kind of complex, so I would like to avoid
joining the result of the query with itself, for performance reasons.
Thanks a lot for helping !
Best regards,
Arnaud
Received on Tue Jun 22 2004 - 12:28:02 CEST