Questions tagged [hierarchical-query]
146 questions
-1
votes
1 answer
Add column with unique row value
I have a table like this:
SELECT
parent_id,
parent2_id,
parent3_id,
parent4_id
FROM
parents
I need to make it like this:
I need to add column with an unique value of a row, but since we have 4 columns, then there…

Zaoza14
- 61
- 4
-1
votes
1 answer
How to Concatenation Parent-Child Rows on Hierarchical table in SQL Server?
I have a table Address and I want to Concatenation rows like parent-1 => parent-1/all-child, parent-2 => parent-2/all-child so on ....
Address Table
ID Caption Parent
---------------------
1 A NULL
2 B NULL
3 a …

Zanyar Jalal
- 1,407
- 12
- 29
-1
votes
1 answer
Extract all rows of a column based on the value of another column (SQL query)
I have table
a | b
-----
1 | 3
3 | 2
3 | 4
2 | 5
3 | 6
2 | 7
how to write sql query if a = 1 then result 3 2 4 5 6 7, if a = 3 then 2 4 5 6 7, if 2 then 5 7
here is my query
select *
from table
where a in (select b from table where a = 1)…

Tôm Leè
- 7
- 6
-1
votes
1 answer
What's the best data structure for a hierarchical BOM
I am trying to work out the best schema structure to represent a BoM in Postgres. Assuming a part can have multiple of the same child part, I could add a quantity column, but those parts may also have multiple children.
If I wanted to know the total…

PrestonDocks
- 4,851
- 9
- 47
- 82
-1
votes
1 answer
issue with hierarchical queries in db2
I have the following tables
Lead
id varchar
employee_id varchar
Employee
id varchar
lead_id varchar
There will be a group of employees assigned to a lead. The Lead table holds the employee id of the lead.
The employee table will have lead_id…

Sachi
- 1
- 1
-1
votes
1 answer
I want to insert one billion records in the oracle database
I have to insert one billion record in oracle database table.
I have 2 column .
One column is a seqence number which follows till 1,000,000,000
Second column is a varchar2 field ... and it is in the format of abc~122~373~7777777~5367
. That is first…

Chirag Karnawat
- 13
- 3
-1
votes
1 answer
SQL hierarchical query up to 10 level
I want to write a SQL Server SELECT query to display data in hierarchical in tabular format.
Like: employee reports to X manager, then X manager reports to XX manager, and then XX manager reports to XXX manager - for each line of record.
Table…

user3530807
- 19
- 1
- 4
-1
votes
1 answer
Required Oracle Query to populate Hierarchies
Background...
As part of existing data conversion we need to convert to populate Adhoc Hierarchies with a limited information.
Currently we have a finger countable members from CXO House treated to be users of this Adhoc Hierarchies.
They have their…

user1089783
- 63
- 2
- 8
-1
votes
1 answer
How to convert the the oracle query to PostgreSQL to get the count of table
I want to convert the mentioned oracle query to PostgreSQL for getting the count of table
select count(*) from student connect by prior std_id=std_roll

Nayan Arora
- 79
- 1
- 3
-1
votes
1 answer
oracle sql hierarchical queries
I have two tables:
CREATE TABLE CATEGORY (
cat_id NUMBER PRIMARY KEY,
cat_ust_id NUMBER REFERENCES Category( cat_id )
);
CREATE TABLE PRODUCT (
cat_1 NUMBER REFERENCES Category( cat_id ),
cat_2 NUMBER REFERENCES Category(…

Bazaaran Corbi
- 1
- 3
-2
votes
2 answers
Query to write latest changed customer id
Тhe customer id get updated regularly. There is a table
that records this change.
Customer id, Customer’s Previous id, Customer’s Successor id
100,95,102
101,96,105
102,100,104
103,99,106
107,88,111
We need from this data for each customer id, that…

Pushpak Kumar
- 7
- 2