2,102 questions
0
votes
1
answer
23
views
Traversing graph using recursive CTE - using "array" to store visited vertices
I'm studying graph traversal using recursive CTEs (learnSQL course). The question asks about visiting every city from a starting city. They use a "path" string built up from appended city ...
0
votes
1
answer
84
views
ORACLE Query for all connected records
I have a joining table that performs a two-way binding using a single record.
In the example below, the record with id=8 is linked to the record with id=4, and the record with id=4 is linked to the ...
-5
votes
1
answer
57
views
Trouble with recursive query in redshift
Considering following test data:
CREATE TABLE products_su
(
country varchar(2),
intprd varchar(20),
period date,
su int
);
INSERT INTO products_su (country, intprd, "period&...
2
votes
4
answers
100
views
Recursive query to figure out record which creates circular dependency
I have a postgress table incoming_records which contains 2 column supervisor_id, emp_id
create table incoming_records(supervisor_id,emp_id)as values
(null,01) --top level resources with blank ...
1
vote
2
answers
100
views
Multiple recurrence within redshift/postgres recursive query
I'm seeking help with including deeper recurrence then last row with recursive query. Source data:
CREATE TABLE products_su(country, intprd, "period", su)AS VALUES
('GL', 'Medicine', '2019-...
1
vote
1
answer
59
views
oracle query to loop through multiple records and provide the results [closed]
oracle query to loop through multiple records and provide the results
Please help qrite an oracle query to achieve above results.
input data
ID
ABRV
NXTFILL
DAYSOUT_INT
DAYSOVER_INT
TIME
123
abc
null
...
1
vote
1
answer
51
views
Recursive CTE with cycle detection using path array
I have a recursive CTE definition (graph) in Postgres that involves cycle detection: fiddle
CREATE TABLE relationships (
subject_type,
subject_id,
subject_relation,
resource_type,
...
0
votes
1
answer
95
views
CTE query for hierarchical data excluding some records despite having full hierarchy [closed]
I have a table that stores hierarchical data, where each record may have a parent_item_code referencing another record in the same table. I'm using a Common Table Expression (CTE) to build the full ...
0
votes
1
answer
76
views
Mysql slow recursive query with many join
I have a complexe query to make statistics on few tables.
I need, for each party and each thematic the number of vote between a member and a party + the number of vote with the same value (member_vote....
0
votes
1
answer
62
views
Recursive CTE 'Query Error: relation [] does not exist', PostgreSQL v17
Practicing some SQL from Danny Ma's case studies. Working on number 3, found here. The challenge question that I'm requires an iterative table of payments made during 2020.
I'm scaffolding up to my ...
0
votes
0
answers
73
views
Recursive pgsql with sorting by level, prioritizing descendant and seq_no
lets say i have a root node and the root has child and said child have n number of siblings and their own descendants. i know i'm supposed to use recursive cte for such but my query would only return ...
2
votes
2
answers
93
views
Recursive query to calculate folder size including nested files
I have a table in my Postgres 17 database where both files and folders are stored. If type = 'folder', then it represents a folder; otherwise, it's a file. By default, the size field is set for all ...
1
vote
1
answer
89
views
Recursive CTE in Firebird for calculating aggregate costs in hierarchical data
Consider the following tables:
create table WORKS_WITH_BASE_COSTS
(
CODE integer not null,
BASE_COST decfloat default 0 not null,
constraint PK_WORKS_WITH_BASE_COSTS primary key (CODE)
);
...
0
votes
1
answer
41
views
Update Postgres Pedigree process to prefix child decendents with @ character
I had assistance in creating a Postgres Pedigree process for plant breeding in 2012 via PostgreSQL Recursive via 2 parent/child tables. The pedigree parent/child hierarchy is defined by the family/...
-2
votes
2
answers
101
views
Identify the users with minimum votes and allocate new votes to that user
I came up with one problem where I am looking for a solution as I have two tables:
Table1: Users
UserID
TotalTasks
A3
12
A4
14
A5
11
Table2: Tasks
TaskID
NewTask
1
4
2
5
3
3
4
2
Output:
TaskID
NewTask
...