What is the best way in oracle to ge the following result set from a table like this:
GROUP ID VALUE
--------------------
1 1 A
1 2 B
1 3 C
2 4 D
2 5 E
3 6 F
4 7 G
4 8 H
ID Parent VALUE
---------------------
1 0 A
2 1 B
3 2 C
4 0 D
5 4 E
6 0 F
7 0 G
8 7 H
Essentially what this is doing is taking data that is grouped by a certain number and making a parent child relationship out of the entries in the group.
The point of doing this is to add it to a connect by query to return the values in one column separated by commas.
Now I can do it with a bunch of sub queries and lag functions, but it seems like there would be a quicker way to do it.
Or..am I totally missing something and can directly use the connect by prior command on the original data. That would be optimum!
EDIT
It seems like I may have confused the situation. My ultimate goal (but not the question here) is to query group number 1 and get the result A,B,C as a string in one single column.
I know how to do that with the Connect by clause. That is not the issue.
The issue is that in order to use the connect by clause you have to actually have the data in a hierarchical format.
That is what I'm looking for a more efficient way to do.