Questions tagged [self-join]
The self-join tag has no summary.
50 questions
1 vote
1 answer
250 views
Issues with Self-Referencing Foreign Key in SQLite
I'm having trouble with a self-referencing foreign key in SQLite. I've created a table to store employee details, where each employee can have a manager who is also an employee. Here's the table ...
1 vote
1 answer
139 views
Bidirectional self join table
Consider: CREATE TABLE object ( id integer NOT NULL DEFAULT nextval('object_seq'), ..., CONSTRAINT object_pk PRIMARY KEY (id) ); CREATE TABLE pairing ( object1 integer NOT ...
0 votes
0 answers
762 views
T-SQL, Fast self join on the next available date where dates skip weekends and multiple rows can have the same date
TL;DR, I'll post back later with more info including table, view, and index definitions; before/after results; and query plans to help to answer this question. I'm trying to use a self-join to a view ...
0 votes
1 answer
706 views
How to optimized self-join view of 50 millions rows table
I've the following simplified table with ~50M rows. table sample ( id uuid not null primary key, measured_date timestamp with time zone not null, segment_id uuid not null, activity_id ...
0 votes
2 answers
162 views
Improving query (Doing a nasty self join on a range with ctes)
-- The CTE1 is just to create columns that dictate the bound of what is considered the same entry -- Also I do a dense rank by ACT_TIME, and a PARITION BY on ID1, ID2 -- so all ID1/ID2 combos are ...
2 votes
0 answers
926 views
SQL Server - Self join on table is very slow
Working with Microsoft SQL Server 2017 (RTM-GDR) (KB4505224) - 14.0.2027.2 (X64) We have a single table, which is planned to contain about 1.5 - 2, maybe max 3 million records at a time. Records will ...
0 votes
0 answers
25 views
How do I join rows from the same table with slightly different info?
We have a new sector of our company that is being put into our employee record feed. However this sector is listed as contractors as there are still parts of the sector that need access to systems ...
0 votes
2 answers
146 views
Explaining what the OR operator does in the following code
I ran into the following SQL code which (successfully) outputs a list of parents and the age of their youngest child: SELECT parents.name AS name, MIN(children.age) AS age FROM people children INNER ...