Questions tagged [hierarchical-query]
146 questions
4
votes
1 answer
Hierarchical Query / base on table input
Account table:
ID_ACC PARENT_ACC
76543 76543 <-edit
18252 76543
34456 76543
456567 76543
457564 65424
45654242 6556756
Info table:
ID account_id product_id
…

bazyl
- 263
- 1
- 7
- 17
3
votes
3 answers
Need an Oracle hierarchical query that returns only full trees for records where children match a search string
Here's the full example data set for this query without any pruning of trees where no node matches the search string:
Level parent id text
---------------------------------------------
0 0 1 toplevel
1 1 2 …

bchesley
- 151
- 1
- 3
- 8
3
votes
1 answer
Oracle SQL start with/prior
I've successfully mananaged to understand how the connect by level works with the below example:
SELECT
level,
t.*
FROM
(
SELECT
'a' AS col1,
'b' AS col2
FROM
dual
UNION ALL
…

Javi Torre
- 724
- 8
- 23
3
votes
1 answer
How to find the imporper data that cause ORA-01436
I have a query to see the parent and child hierarchical list of data. On running the below query i got the error ORA-01436.
SELECT ParentPropertyRSN, CONNECT_BY_ROOT PropertyRSN as PropertyRSN,
LEVEL, SYS_CONNECT_BY_PATH(ParentPropertyRSN, '/')…

Suwaid Akbar
- 127
- 1
- 8
3
votes
2 answers
Ignoring single childs (bamboo parts) in hierarchical query
I have a table with hierarchical data as follows.
create table tst as
select 1 id, null parent_id from dual union all
select 2 id, 1 parent_id from dual union all
select 3 id, 1 parent_id from dual union all
select 4 id, 2 parent_id from dual union…

Marmite Bomber
- 19,886
- 4
- 26
- 53
3
votes
2 answers
Find hierarchical or parent-child column values from a single table oracle
I have a table name tree and it have two columns one is p and second one is ch.
p ch
-------------
1 2
1 3
1 4
2 5
2 6
7 8
9 10
11 12
6 13
13 14
14 15…

Ankur Bhutani
- 3,079
- 4
- 29
- 26
3
votes
2 answers
How can I get a distinct list of elements in a hierarchical query?
I have a database table, with people identified by a name, a job and a city. I have a second table that contains a hierarchical representation of every job in the company in every city.
Suppose I have 3 people in the people…

aw crud
- 8,791
- 19
- 71
- 115
3
votes
1 answer
Oracle SQL Hierarchical Query to know path between two Elements
1
|
+----------------+-------------------+
| | |
2 7 9
| | |
+--+--+ …

Pratik Bhopal
- 61
- 1
- 7
3
votes
2 answers
PostgreSQL Hierarchical, category tree
ENV : postgresql-8.4
I'm trying to build a category tree . Basically I'm expecting a final output such :
categoryName
categoryPath
leafcategory
e.g. :
Digital Camera
Electronics ::: Digital Camera
true
The table structure is
CREATE TABLE…

themihai
- 7,903
- 11
- 39
- 61
2
votes
1 answer
MS SQL Server - How to create a view using hierarchical query
I would like to create hierarchical query using with and removing 4 join, someone can help please i am beginner in SQL views.
CREATE VIEW CAR( ID, CARLEVEL) AS
select
t.C_ID,
coalesce(d.C_ID, coalesce(c.C_ID, coalesce(b.C_ID,
coalesce(a.C_ID,…

satcha
- 129
- 1
- 13
2
votes
1 answer
Recursive CTE to get top level results
Here is my current data set.
| BIMUnique | Description | Quantity | SuperiorUnique | LineCode |
|-----------|--------------------------------------------|----------|----------------|-----------|
| 660084 | Top Level…

user2962869
- 91
- 8
2
votes
1 answer
How to show grand parent on sql hierarchy?
So this is my table:
id |parent_id |name
-------|-----------|--------------------
1| 0|Kevin Gravey
2| 0|John Chen
3| 1|Clark Garvey
4| 2|Halsey Chen
5| 3|Carl…

parker
- 67
- 5
2
votes
3 answers
Generate hierarchical path
I have a classstructure table:
create table classstructure (classstructureid number(8,0), classificationid varchar2(25), parent number(8,0));
insert into classstructure(classstructureid, classificationid, parent) values(1001, 'FLEET', null);
insert…

User1974
- 276
- 1
- 17
- 63
2
votes
1 answer
Splitting a Path Enumeration Model PathString in MySQL
I'm trying to implement a Path Enumeration model as per Joe Celko's book (page 38). The relevant attributes of my table (and the support table that just contains sequential integers) look like…

codemonkey
- 2,661
- 2
- 24
- 34
2
votes
3 answers
searching DBMS with hierarchical structure
Is there any open-source hierarchical database or emulation atop of existing RDBMS?
I am searching a DMBS (or plugin to existing RDBMS) which can store hierarchical data and permits to perform queries on hierarchical data (something like "SELECT…

ts.
- 10,510
- 7
- 47
- 73