2,095 questions
-2
votes
1
answer
65
views
MySQL order by id but prioritize an empty value of a certain column
Mainly, I want to order the ids in descending direction but also, how can I sort parent product/items (the ones with empty ean) first and their child rows below them?
Here's an example data from the ...
457
votes
17
answers
471k
views
How to create a MySQL hierarchical recursive query?
I have a MySQL table which is as follows:
id
name
parent_id
19
category1
0
20
category2
19
21
category3
20
22
category4
21
...
...
...
Now, I want to have a single MySQL query to which I simply supply ...
581
votes
15
answers
145k
views
What is the most efficient way to parse a flat table into a tree?
Assume you have a flat table that stores an ordered tree hierarchy:
Id Name ParentId Order
1 'Node 1' 0 10
2 'Node 1.1' 1 10
3 'Node 2' 0 ...
2
votes
5
answers
95
views
Dropping grouped rows based on a certain hierarchical column
Suppose I have this pandas dataset:
ID
Question Code
1
Q01
1
Q01-1
1
Q02
2
Q01
2
Q02
2
Q02-1
2
Q02-1-1
2
Q02-2
I want to remove the rows based on certain hierarchical conditions between the values of ...
-2
votes
2
answers
160
views
Query to find all members of multi level many to many relationships and also the top most member of the hierarchy
Multiple student can go to 1 teacher, but 1 student can't go to multiple teacher. There is no limit of level in this teacher student hierarchy.
How using a single SQL query in SQL Server we can get ...
0
votes
0
answers
51
views
Hierarchy Transformation/Looping using Pyspark, Python
I have some SAS code and need to convert it to PySpark code.
Hierarchical SAS Code Part (1)
if cc1 = 1 then do i = 2, 3; cc(i) = 0; end;
if cc2 = 1 then do i = 3; cc(i) = 0; end;
Basically, this code ...
0
votes
1
answer
98
views
How to introduce a random error within a Bayesian count model?
I am trying to model counts distribute across groups in JAGS, but I need to add a random effect for the presence of multiple counts from the same individual.
The model is taken from here
enter link ...
1
vote
1
answer
167
views
Hierarchy between employee for each department
I have to build a hierarchy between all the employees working in an organisation department wise.
For e.g. An organisation ABC has 2 departments - Sales, Marketing
Each department has multiple ...
1
vote
1
answer
56
views
How to use recursive function for product transition? [closed]
In Oracle SQL, I have a product transition table named kit_transition_mapping that is a slowly changing dimension and an orders table. For an order_no based on the order_date, I need to utilize the ...
1
vote
3
answers
101
views
Oracle SQL hierarchical query data accumulation
I need to accumulate data in hierarchical query like this:
select
id,
prior id as parent_id,
count * prior count --need to be accumulated through whole hierarchy like sys_connect_by_path
from ...
0
votes
2
answers
63
views
Transpose Hierarchical Table based on leaf nodes with nodes as first column
I have a hierarchical table categories as follows:
id
name
parent_id
1
Accommodation
null
2
Transport
null
3
Utility
1
4
Maintenance
1
5
Private
2
6
Public
2
7
Electricity
3
8
Gas
3
9
Internet
3
10
...
0
votes
1
answer
122
views
how to store tree structure in database?
I want to save and restore a tree structure in mysql database ?
I try to save it by adding "parent_id" field to reference the id of parent row.
the parent but it can reference to each other ...
0
votes
0
answers
69
views
Creating Node-Specific Tree Diagrams with Pyvis or Alternative Libraries?
I am working on generating hierarchical graphs using Pyvis. In my case, the nodes are not all connected to each other, so I would like to implement a dropdown menu that allows selecting a node by name....
0
votes
1
answer
127
views
Flag all bosses in meeting based on org tree
My task is to flag "boss level" participants in data collected from meetings, based on a given org chart.
In other words, it needs to identify the highest ranked individual(s) within the ...
123
votes
7
answers
140k
views
Simplest way to do a recursive self-join?
What is the simplest way of doing a recursive self-join in SQL Server?
PersonID | Initials | ParentID
1 CJ NULL
2 EB 1
3 MB 1
4 SW 2
...
0
votes
1
answer
260
views
Calculating robust SEs following full matching (MatchIt) with mixed-effect models (lme4)
I am attempting to estimate a treatment effect for a study that features both (a) hierarchical data (students within classrooms; implemented with lme4) and (b) matching between treatment and control ...
4
votes
1
answer
154
views
Bottom-up tree structure cumulative sum
CREATE TABLE Emissions (
entityId VARCHAR(512),
parentId VARCHAR(512),
emission DECIMAL,
percentContribution VARCHAR(512)
);
INSERT INTO Emissions (entityId, parentId, ...
30
votes
10
answers
4k
views
Is there a way to convert CSV columns into hierarchical relationships?
I have a csv of 7 million biodiversity records where taxonomy levels are as columns. For instance:
RecordID,kingdom,phylum,class,order,family,genus,species
1,Animalia,Chordata,Mammalia,Primates,...
0
votes
1
answer
313
views
Multi-level hierarchy data display
I want to fetch a multi-level hierarchy in a sequential manner. I have a table BOMHierarchy in which I have this sample data:
Parent
Child
Parent1
Child1
Parent1
child2
Child1
Child3
Child1
Child4
...
0
votes
2
answers
120
views
Multiple column Tree Hierarchy (Manager, Employee) in Oracle Sql
I have an employees table as below :
EMPLOYEE_ID
FIRST_NAME
LAST_NAME
EMAIL
PHONE_NUMBER
HIRE_DATE
JOB_ID
SALARY
COMMISSION_PCT
MANAGER_ID
DEPARTMENT_ID
103
Alexander
Hunold
AHUNOLD
590.423.4567
38720
...
0
votes
1
answer
46
views
Extrapolating self-referencing keys from a hierarchy column
I'm working with a dataset in MySQL that includes a hierarchy column with formats like:
1
1.A
1.A.1
1.A.1.a
1.A.1.b
1.A.2
1.A.2.a
1.B.1
1.B.1.a
2
2.A
...
I'd like to build a table with a self-...
73
votes
9
answers
82k
views
How to represent a data tree in SQL?
I'm writing a data tree structure that is combined from a Tree and a TreeNode. Tree will contain the root and the top level actions on the data.
I'm using a UI library to present the tree in a windows ...
0
votes
2
answers
65
views
Weighted hierarchical cumulative sum
I don't know if I'm using the correct terminology, but I'm trying to find the cumulative sum of each node in a tree structure, but the children node only contribute a percentage of its cumulative sum ...
0
votes
0
answers
35
views
How to connect 20 same kind of tables in PowerBI?
I have excel workbook containing budget data on yearly basis. The budget is divided into certain categories and these categories are following a hierarchy. The columns of the sheets are as follows.
...
0
votes
2
answers
143
views
Mysql 8 recursive query with two mandatory parents
I am working with a hierarchy problem where the nodes have two parents and need get only the nodes where both parents are in the result.
In the happy world, this query would be perfect
WITH RECURSIVE ...