'Need to know if SQL Oracle can output a certain hierarchical style
Needing to know if this is possible.
I'm trying to get a hierarchical output looking like this:
TITLE|CHART|FUND|ORGN|PROGRAM
S |S |null|null|
S |S |1 |null|
S |S |1 |10 |
S |S |1 |10 |1
S |S |2 |null|
Is this possible to accomplish in SQL Oracle?
I can't figure out the proper verbiage for this and that's why I'm asking here.
Solution 1:[1]
Your sample result doesn't look hierarchical,
hierarchical queries usually have a tree structure and a CONNECT BY
clause.
You can probably get the required result by using the ORDER BY
clause as follows:
SELECT TITLE, CHART, FUND, ORGN, PROGRAM
FROM employers_data_table
ORDER BY TITLE
,CHART
,FUND ASC NULLS FIRST
,ORGN ASC NULLS FIRST
,PROGRAM ASC NULLS FIRST
Solution 2:[2]
In case anyone comes across this, the answer I found was to use unions.
Thanks Crowne for your answer, it definitely helped.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | crowne |
Solution 2 | Randy Laird |