Questions tagged [outer-join]

An outer join defines a relationship between two tables where all records from one or both tables are returned regardless of the existence of a matching key-field in the other table. A full outer join combines the results of both tables. A left or right join returns all the records from the first or second specified table, respectively. NULLS are filled in for matches on either side. A self-join compares a table to a copy of itself.

Filter by
Sorted by
Tagged with
-2 votes
1 answer
42 views

Get percent of column value count compared to same column value count in another table during certain time period grouping by column value

Looking for share of each Agent's rows where task = 'Stalking' in table Stalking compared to occurrences in table Assigned during Min and Max stalkDate in table Stalking. Table Assigned Agent task ...
Kaptah's user avatar
  • 9,781
0 votes
0 answers
11 views

Keep unmatching monthly values from two tables in a many to many scenario in pyspark

I have two tables 'Solution' and 'Project'. There is a many to many relationship between them. Both tables are tracking 'revenue' at monthly level but there can be certain months where Solution only ...
IA39's user avatar
  • 35
0 votes
1 answer
29 views

SQL joining 2 tables to fill blank fields

I have 2 tables and want to join them. Table1: Period Sale Q1 30$ Q2 40$ Table2: Period Sale Q1 10$ Q2 as you can see, Table2 has no Sale-Value in Q2. Now I want to fill this field with the ...
furgun's user avatar
  • 11
0 votes
0 answers
47 views

SQL Server : left outer join on multiple tables

I have a query like this: SELECT post_id, title, publish FROM TABLE_A FULL OUTER JOIN TABLE_B ON ( TABLE_A.post_id = TABLE_B.post_id ) LEFT OUTER JOIN TABLE_C ON ( TABLE_B.publish = ...
Oosutsuke's user avatar
-1 votes
1 answer
55 views

Delete based on the comparison of dependable table between rows of each group of the group by

I have three tables: x (column1,..., x_id) y (column1, column2, colum3, ..., x_id, y_id) z (column1, column2, colum3,..., x_id, y_id, z_id) My final goal: Delete duplicates, check the y table for ...
DRA's user avatar
  • 165
1 vote
5 answers
51 views

Obtain one to one matches from many-to-many linkages, using data.table R

I am trying to link two sets of anonymous ID (ID1 and ID3), via a lookup to another ID (ID2). I want to keep only one-to-one matches between ID1 and ID3, but this is tricky as there are many-to-many ...
rw2's user avatar
  • 1,549
-1 votes
1 answer
32 views

Outer merge two dataframe in python where the left dataframe is larger than the first

I am trying to perform an outer join (union) of two time series in python. The left time series is larger than the first. An example: Right time series - df_1 Time Series 1 3 1 4 2 5 3 Left time ...
TeoTi's user avatar
  • 11
-1 votes
1 answer
32 views

How to do a FULL OUTER JOIN in MySQL and perform GROUP BY a 'column'

Here are my DMLs and DLLs: CREATE TABLE `table1` ( `id` int NOT NULL DEFAULT '0', `email` varchar(100) NOT NULL, `value1` double DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=...
Nikhil Johny's user avatar
2 votes
1 answer
44 views

How to get data from three joined tables, and always show data from 1st, and nulls or existsing records from 3rd?

I have three tables, Roles, Users, and connecting table. I want to show all roles, and existence of it for particular user. Basically a table with roles, which check box "in role" on the ...
sam sergiy klok's user avatar
0 votes
2 answers
61 views

SQL left outer join with where condition

I am new to SQL and learning joins. Please consider the two queries below: When I run the first query below: select count(*) from products p left outer join order_details_v od on p.product_id = od....
DumbCoder's user avatar
  • 233
1 vote
1 answer
55 views

SciPy equivalent of np.minimum.outer

I need to do the outer product of two (large) sparse vectors, taking a minimum of the values instead of multiplication. I need an efficient way to perform this. The build-in point-wise multiplication ...
david brick's user avatar
0 votes
1 answer
42 views

Multiple jointures Errors - SQL (Snowflake)

I am new to coding and I am struggling with a particular use case. I have database A which is like this : Date Segment Product Attendance Date1 A B X Date1 A C Y Date2 A B Y Date2 A D Y I have a ...
EnzoD's user avatar
  • 1
0 votes
0 answers
30 views

KStreams outerjoin acting like innerjoin

I am using .outerJoin to join two streams together. The expected behaviour is that I would get a record in the output for all records in both inputs; but actually I'm only getting an output where ...
simonalexander2005's user avatar
-1 votes
1 answer
22 views

Combine more than 3 data.frames while keeping the extra-rows from the master file that didn't match

I have the following data.frame "A" in R: ID 1 456 200 550 110 and the following data.frame "B" defined in R ID Interaction Student Date 1 email_sent Isabel Gauss 10/20/...
jsaab's user avatar
  • 15
1 vote
1 answer
79 views

Join operation equivalent of nested for loop for pyspark?

I have below tables - Audit ID Customer ID Budget TimeStamp 1 123 100 2023-05-01 07:40:56 2 456 70 2023-05-01 12:20:50 3 456 70 2023-05-01 17:30:50 Audit ID Product ID Price TimeStamp 5 5556 5 ...
Codemaster's user avatar
-1 votes
1 answer
38 views

Full outer join not working, got a multi-part identifier could not be bound error [closed]

I am doing a full outer join of two tables, but received the multi-part identifier could not be bound error. I couldn't figure out why as I have checked everything else. SELECT A.INTEGRATION_ID, ...
Chloe's user avatar
  • 17
0 votes
2 answers
46 views

How to Include zero-count when joining 3 tables?

I have 3 tables: Vehicle, type and color Vehicle id brand type_id color_id 1 Toyota 1 2 2 Toyota 2 3 3 GMC 2 1 4 BMW 2 1 Type id name 1 ...
Plateau The Small's user avatar
0 votes
3 answers
194 views

Update one Pandas dataframe from another and append rows if needed

I have the following dataframes in Pandas: df1: index column 1 A1 2 A2 df2: index column 2 A2_new 3 A3 I want to get the result: index column 1 A1 2 ...
Ars ML's user avatar
  • 71
1 vote
0 answers
66 views

Pyspark: Join two dataframes which doesn't have a common column (The order of the rows should remain same)

I have a spark dataframe(df) consisting of features on which my model is trained on and 3 extra features ID, label and status(these 3 are not used in my model training). I'm using a model registered ...
anaktha's user avatar
  • 21
2 votes
4 answers
46 views

Side-by-side comparison of df's with duplicates_dropped

I have the following very basic df's: df1: A B 0 1 4 1 2 5 2 3 6 df2: A B 0 1 4 1 2 7 2 3 6 I would like to have a comparison of them where the result is showing ...
Rip_027's user avatar
  • 203
1 vote
2 answers
32 views

Is there a way to move the description of the ID through a JOIN?

I am working with two tables (question and question_typ) and im trying to get the definition of the question over without hard coding in case it changes. Is there a way to do this through a join? Here ...
ineedhelp's user avatar
-3 votes
1 answer
62 views

How can I combine two virtual tables from one table, assigning half the data to a new column, without losing data

I have a table formatted as such age height name 15 180 george 16 192 phil 20 148 lily 17 187 george 19 196 phil 24 147 lily 19 190 george 20 199 phil 22 148 lily 21 190 george 27 197 phil ...
AlbinoRhino's user avatar
0 votes
2 answers
120 views

Merge dataframes without duplicate rows with NA values

I have data from multiple files that have data hourly observations for different variables. I'm trying to combine them to a single dataframe where I have every observation for each variable for the ...
SPI_4324's user avatar
0 votes
2 answers
74 views

Conditions with Outer Join

In a where clause I want to return all records with an 'E' at the end of the CRSE_NUMB or all records that have an 'AS' code in ASCD_CODE. Is it all right to add this OR condition in the where ...
RTC's user avatar
  • 23
-1 votes
1 answer
35 views

Merging .csv files in Pandas and two of them end up ~100x their initial # of rows

We are trying to outer join several csv files, each containing two columns. The column we're joining on (NMI, which we make the index) is a unique identifier and mostly overlaps between each file (...
ExeGM's user avatar
  • 1
0 votes
0 answers
17 views

How can this insert query be optimized?

To start off: Generally speaking, the EXISTS operator is faster than IN operator if the result set returned by the subquery is large. By contrast, the IN operator is faster than the EXISTS operator ...
Thomas Freedman's user avatar
0 votes
1 answer
117 views

OUTER APPLY REMOVE DUPLICATES

I have used outer apply to pull the most recent careID and diagnosis date and then used aggregation function to count the total. The code worked, however as soon as I added another join which is: ...
user avatar
-1 votes
1 answer
125 views

Full Join and get left table columns always populated even if they are null

I have these two tables in bigquery: Lets say table people Name Country Continent Adam null 55 Adam 1 55 Josh 4 55 Josh null 55 Josh 3 55 And table country: Country Continent 1 55 2 55 3 55 ...
elvainch's user avatar
  • 1,369
-1 votes
1 answer
58 views

SQL Join is bringing in too many columns

I have two data sets: attendance at a day care in September & attendance at a day care in October. The columns in the data sets are student ID, first name, last name, and then each date of the ...
Skylar Smoot's user avatar
-2 votes
1 answer
89 views

Selecting the same field twice and joining to it twice in an SQL query

marketing_interaction marketing_interaction_id 1 organization_id 75 contact_id 18 internal_person_id 97 description Followup with client person person_id 18 97 first_name John Adam last_name ...
Zephyrus's user avatar
3 votes
1 answer
86 views

You're trying to access a column, but multiple columns have that name

I am trying to join 2 dataframes such that both have the following named columns. What's the best way to do a LEFT OUTER join? df = df.join(df_forecast, ["D_ACCOUNTS_ID", "D_APPS_ID&...
x89's user avatar
  • 2,902
-1 votes
1 answer
32 views

Self join left outer (all from first matching from second)

How do I join a dataframe with itself using left outer (all from first matching from second)? Not sure if this is correct df.alias('d1').join(df.alias('d2'), how = 'leftouter') Edit 1 df = spark.read....
chintan s's user avatar
  • 6,178
-1 votes
1 answer
34 views

Multiple SQL Joins on Two Tables

I need to create 1 table based on matching the records of two tables, lets call them table p and table c, in SQL Server. The manual way to do this in Excel is to match the Order Column in table p with ...
Conner McCoy's user avatar
0 votes
1 answer
123 views

FULL OUTER JOIN - Result rows are showing in different order than expected [duplicate]

I am following a tutorial for learning SQL and working on Google BigQuery Sandbox. For FULL OUTER JOIN my result is showing in different order than the result in the video. How can I fix this? (P.S. I ...
noob_maXPro_scientist's user avatar
0 votes
1 answer
30 views

hown position of joined tables influence results?

I have this question to solve: How can you output a list of all members, including the individual who recommended them (if any)? Ensure that results are ordered by (surname, firstname). which I ...
S. R.'s user avatar
  • 69
0 votes
2 answers
58 views

Outer join removing duplicated columns

I'm trying to joint multiple data obtained trough a query like this: select TO_VARCHAR(CREATE_TIME, 'yyyy-MM') as YEAR_MONTH, COUNT(1) as DESIRED_VALUE from MY_TABLE ...
pceccon's user avatar
  • 9,449
-1 votes
1 answer
23 views

Oracle Query not giving result though outer join is present

In the below query when i comment one line AND EVT.EVT_EVNT_ID(+) = DPT.DPT_EVNT_ID or add outer join (+) in one line AND EVT.EVT_ENTITY_ID ='G' the query will fetch results, else it will not give any ...
user3923942's user avatar
0 votes
0 answers
59 views

Merging data onto empty data frame produces NAN and NAT values

I have been unsuccessful so far in trying to merge my dataset onto an empty data frame with exactly 10 readings per second (864,000 rows) with two columns ('x' & 'y'). My data is randomly missing ...
caad8123's user avatar
-2 votes
1 answer
83 views

Query with Left outer join and group by returning duplicates

To begin with, I have a table in my db that is fed with SalesForce info. When I run this example query it returns 2 rows: select * from SalesForce_INT_Account__c where ID_SAP_BAYER__c = '3783513' ...
FranciscoFJM's user avatar
-2 votes
1 answer
195 views

how to write more than one joins in Big Query

I want to convert following Oracle query into equivalent Big Query SQL. Below is old syntax of right join but same operator (+) is not available in Big Query. SELECT * FROM t1,t2,t3,t4,t5,t6,t7,t8,...
user3219871's user avatar
0 votes
1 answer
81 views

R data.table rolling join creating extra rows

Working with data.table's rolling join functionality, I noticed some extra rows being created in my data. I tried replicating this issue on a smaller scale: A <- data.table(id = c(1, 2, 2, 3), ...
Algebro1000's user avatar
1 vote
3 answers
33 views

Merge overlapping datasets by column identifier?

I am trying to merge/join two datasets which have different data about the same samples with no rows in common. I would like to be able to merge them by the column names and have that add the rows ...
sscoresby's user avatar
0 votes
3 answers
150 views

ORA-01799: a column may not be outer-joined to a subquery

I have below query that returns me error message "ORA-01799: a column may not be outer-joined to a subquery”, how do I make it right? Thanks in advance for your help! delete from TRN_HDRF_DBF ...
Amy's user avatar
  • 3
0 votes
1 answer
84 views

How to list all columns an PK name for relevant columns in Oracle

I want to display all columns of a table and the Primary Key name for a column, if that column belongs to the PK. So, expected final result will be a 2 column output, the first being the column_name ...
Jay's user avatar
  • 67
0 votes
1 answer
46 views

Full join on multiple columns not working - mySQL 5.7.36 on wampserver64

I have 2 tables (Table_1 and Table_2) that I would like to merge into a new table: Table_1: Variable_A Variable_B Variable_C Variable_D 1 2 3 4 Table_2: Variable_A Variable_B Variable_E Variable_F ...
ellena's user avatar
  • 9
-1 votes
1 answer
44 views

MySQL to fill in the blanks with NULLs when their isn't a row based on set number of IDs from the join

Looking to fill in the blanks with NULLs when there isn't a record that is for a row that I am expecting. Consider the following wp_posts (p) ID post_title 1 Week 1 2 Week 2 3 Week 3 4 Week 4 5 ...
Bobby S's user avatar
  • 4,006
-1 votes
1 answer
23 views

Postgres: Select multiple but show records where linked field isn't present

I have multiple tables in my Postgres database that are linked by a field called id. My main table, Person is linked to other tables Address, Phone andEmail by id. This line of code gets information ...
George Shalhoub's user avatar
0 votes
1 answer
66 views

Timetable outerjoin without sorting on keys

I am trying to find a way to perform an outerjoin of two timetables containing the same variables, while not sorting the merged rows of keys based on value. I want to give preference to values from ...
WJB's user avatar
  • 133
0 votes
2 answers
84 views

Outer join to check existence each records of two pandas dataframes like SQL

I have to tables looks like following: Table T1 ColumnA ColumnB A 1 A 3 B 1 C 2 Table T2 ColumnA ColumnB A 1 A 4 B 1 D 2 in SQL I will do following query to check the existence of each ...
Wei Songhome's user avatar
0 votes
1 answer
45 views

Mysql query to select row based on column value

id date is_available product_id product_recalled 200 2019-10-10 1 123 yes 201 2020-07-10 1 123 no 202 2020-08-11 0 123 yes 203 2021-07-10 0 123 yes 204 2021-01-10 0 123 no 205 2021-07-10 0 124 ...
user3376592's user avatar

1
2 3 4 5
34