Questions tagged [join]
A JOIN is a general operation in relational algebra for a combining operation on two relations in a relational database system. JOIN is also a keyword of the SQL language for performing analogous SQL operations.
43,406
questions
0
votes
0
answers
5
views
Join 2 tibbles without the same length and add "NA" for empty cells
I tried several things posted in the forum but had no success...
If hope I was clear. If not, please tell meI've 2 tibbles named traitement_RPE and traitement_VOL which contain 3 columns named "...
0
votes
0
answers
19
views
JavaScript Objection relation mapping
I am wondering if there is a way to solve my problem.
I want implement this type of join SQL JOIN Records ON Accounts.id = Records.account_id OR Accounts.id = Records.from_account_id; with Objection ...
-2
votes
0
answers
30
views
How do I fix and complete this query?
I have tables customer, borrower, and loan.
customer and borrower share column cust_id
loan and borrower share column loan_number
loan contains column branch_name
customer contains column ...
0
votes
2
answers
32
views
Get row of data for MAX value over GROUP BY and JOINS
I am working with the ml100k dataset to write a query that can fetch me the most rated movie for every age.
Here's how my tables are defined.
users
id | age | gender | occupation | zipcode
ratings ...
0
votes
1
answer
35
views
This join query is only supposed to output 39 rows, but I am outputting 140. What may I be doing wrong that I can do differently? [closed]
I am having a problem where I am wanting to use a join to find what color names are not part of any sets. The expected output is 39 colors, but I output 140 colors.
SELECT DISTINCT a.color_name AS [...
1
vote
1
answer
21
views
Can I create a virtual table in Dax to calculate account balance for products with different expiry dates?
I have product A, B, C. They each have opening balance amount at 1/11/2023 ,say 3000, 7000 and 11000 for A,B,C respectively. They each have expiry dates, say A, B and C expires on 11/11/2023, 5/11/...
-1
votes
0
answers
54
views
Date as a key on join in SQL (multiple dates)
I have two tables, one is for transactions and the other one is for escalations; this is my code:
SELECT * FROM TRANSACTIONS AS A
LEFT JOIN (
SELECT
COMP_ID,
ITEM,
...
1
vote
1
answer
35
views
Overriding column value in SELECT statement based on related table having certain data or not
Given that I have a read-only table Account:
ID
Type
1
Customer
2
Customer
3
Customer
4
Customer
And another RELATED read-only table Policy:
RelatedAccountID
Status
1
Active
1
Expired
3
...
0
votes
2
answers
49
views
Rails Multiple join query
I have the below Model structure
class Transaction
belongs_to :company
belongs_to :user
end
class Company
belongs_to :address
end
class User
belongs_to :address
end
classAddress
has_many :...
0
votes
1
answer
49
views
MIN() in JOIN based of dates
I would like to join two tables based on two common fields. Assume the date is 2024 I want to join the sale table on dictionary table which hold only articles with dates 2022 and 2023. Because of the ...
-1
votes
0
answers
51
views
SQL Join to In-Time Separate tables
I have a large table of data points as well as a column that contains the month of occurance of the datapoint. I also have several other tables that have in-time characteristics at each month.
Main ...
-3
votes
0
answers
40
views
Query returning sum of total payments multiple times instead of each individual payment [closed]
My query joins and pulls form multiple tables and then creates and places the data into another table for report viewing (when report is generated). I expected for the payments to be listed ...
-1
votes
2
answers
73
views
Can I declare a SQL variable based on another table?
Is it possible to set a varible based conditional values?
How I would explain it in layman's terms would be:
I want my variable @L0 set up where if a CompanyCode = A then L0 = 1, If CompanyCode = B, ...
0
votes
1
answer
47
views
kdb/q What kind of Join would I need for this scenario?
I have two tables like this:
participants: each person in the race, along with their score and the name of race they ran in
Name
Score
Race
Ann
66
8a
Bob
20
8a
Ann
73
7d
Bob
25
7d
races: the ...
0
votes
1
answer
25
views
Python - .join() OR .replace() at the start of a loop with range?
Updated
Using Python
Question Summarized:
Is it possible to add a .replace() OR .join() in a loop? Attempting to NOT have to add .replace/.join to every print statement???
Input:
for a in range(1, 10):...
-1
votes
1
answer
27
views
Joining tables in pyspark based on condition
I would like to join pyspark tables where the first table has id, startTime and endTime where as the second table has Time and value. The merged table will have for every id the columns Time and value ...
-2
votes
0
answers
31
views
SQL Server Join tables based on 2 columns
I have working on a table query in order to bring the data from multiple tables, but facing issues to map 2 columns from the parent table to child table.
My scenario will be like this
select *
from ...
-2
votes
3
answers
74
views
How to join tables and sum joined columns in MS Access SQL
I have 3 tables
Table1 - all rows have unique ID:
ID
weight
10501058730
12
10502060832
16
10504063941
45
10507066038
28
Table2:
ID
expense_1
10501058730
9752
10501058730
457
10504063941
238
...
0
votes
0
answers
35
views
Aggregation does not work properly in sql, in a many to many relationship, because of where clause
My setup
I have two tables, watch, and tags. They are in a many to many relationship joined by a table called linked_watch_tags. I have a query, where I JOIN these tables, GROUP the query by the watch....
0
votes
3
answers
91
views
How to display the current info base on date
My SQL script is to display the company, employee number, last name, first name, current job, and current salary.
To arrive at the current something implies there are dates involved.
How do I display ...
0
votes
1
answer
21
views
applying count() across multiple columns in a table referencing the same foreign key
I'm trying to get group counts for music genres on weekly top songs list, where the table for the billboard top songs has multiple foreign keys all to the song's primary key song_id.
E.g.: over the ...
2
votes
1
answer
30
views
What is an effective way of joining two tables given in different formats, using pandas?
I am working with two tables:
df1: Zone column has say, 3 categorical levels whereas the weight column is a continuous column.
id
Zone
Weight
1
A
4
2
B
14
3
C
25
4
A
8.5
5
B
10
df2: The first 2 ...
-1
votes
0
answers
28
views
How do I join the same table twice, and why is it neccesary in this case? [duplicate]
enter image description here enter image description here
I need help solving this question. I don't understand why I need to JOIN the same table twice.
When I try to do 'WHERE category.name = 'Horror'...
0
votes
1
answer
38
views
JOIN multiple tables, concatenate name strings, and hierarchically group data
I have been trying to get details from Contacts table, from Another table with Id's for these contacts, I think it has to do with logic, I am not not a pro yet.
These are my Tables:
...
2
votes
2
answers
55
views
How to find a combination of two columns that is NOT in the other table in ORACLE SQL?
I have a main table that contains the data I have, and a reference table telling me what values the main table should have. I want to check if the main table contains all required values, and if not, ...
0
votes
0
answers
35
views
Error when attempting to full join of two arrow tables in R
I reached out to the package developers on this but wanted to see if anyone else had encountered the same issue.
I'm having a problem where I'm trying to use full_join() on two tables (subset from the ...
0
votes
2
answers
104
views
SQL 43 tables into 1 table
just started exploaring the world of data analysis.
I have a dataset with 43 tables, all tables have same primary key.
How can i create 1 table out of the 43 that i have?
Are joins the only way to do ...
1
vote
1
answer
179
views
+50
How to join two results with Spring Data Specification
How to join two results in while using Criteriabuilder
I am using CriteriaBuilder where I am using two table Student and StudentResult.
When I am querying my API
http://localhost:8080/student?query=...
0
votes
2
answers
53
views
keyword argument or workaround for left join so values of columns are replaced with those of another DataFrame
What is a keyword argument or a workaround for joining DataFrames x and y below in leftjoin!() so that the values of column d within x are replaced with those of d within y instead of returning an ...
0
votes
0
answers
19
views
Inner Join with 2 arrays using JOLT. I want to do a join with two arrays that the objects have the same id.(example below)
I want to do a join with two arrays that the objects have the same id.(example below)
{
"body": {
"array1": [
{
"id": "13910",
"...
-2
votes
1
answer
36
views
In Bigquery Join two tables append all existing values table1 from table2 and where no intersection leave null [duplicate]
Hello stackoverflow community! May I ask to help with query in bigquery
I have table1 which contains user_id and their data
user_id
age
order_name
details
type
1
18
t-shir
item1
new
2
22
skirt
...
0
votes
0
answers
32
views
Joining tables across linked servers vs inserting into temp tables followed by joining in SQL Server
Say my end goal is to join tables from different servers in SQL Server 2019.
I've seen some posts on this and they outline how I must run the sp_addlinkedserver stored procedure which is relatively ...
0
votes
2
answers
48
views
How to write the SQL query so that it doesn't have to run for each day?
I am using Vertica Enterprise for my warehouse.
I have three tables.
Table #1 - Students
Table #2 - Address of Students
Table #3 - Homework progress of Students done for the day. (Note: some of ...
-1
votes
2
answers
65
views
SQL LEFT OUTER JOIN on 3 tables with a joining table in the middle
Tables:
IN
OUT
IN_OUT
I want all of the items from IN, and, if they exist in IN_OUT and OUT, the values from OUT.
SELECT intable.colA, outtable.colB
from IN intable
LEFT OUTER JOIN IN_OUT ...
1
vote
2
answers
121
views
Convert SQL query that uses CASE expression as a JOIN key to pandas
SELECT a.year, a.country, b.amount
FROM table_a a
LEFT JOIN table_b b
ON a.country=b.country
AND (CASE WHEN b.country = 'Europe' THEN b.year = 2022 ELSE b.year = 2023 END)
I am trying to transform ...
-1
votes
0
answers
53
views
Inner joins not giving exact result
I am trying to join three tables. My problem is that the table gmail_message has all emails not present in table lead_contact.
I have to show only the records which match in both tables - this means ...
0
votes
1
answer
29
views
Color column and exclude NA with ggplot2
I would like to color a column but render the NA values one specific color with ggplot2 please.
If we take the world dataset from the spData package.
library(sf)
library(spData)
library(ggplot2)
set....
0
votes
1
answer
55
views
Join calendar table to historical data
I have a specific problem that I don't know how to go around. I have two tables:
companies_with_owners
|Company_ID|Priority|Owner|Created_at|Current_date|Archived|Updated_At|
|----------|--------|-----...
0
votes
0
answers
66
views
How to join a lookup table for multple colums of primary table in SQLite
I have two tables. the employee (lookup) table has empl_id and empl_name plus other fields. The orders (primary) table has order_nbr, cashier_id, cashout_id, and driver_id. These all include ...
1
vote
1
answer
30
views
i am getting "Expected end of input but got identifier "employee_data" at [9:21]" as a return for a query, what might be the problem
I wrote some SQL code and get this error:
Expected end of input but got identifier "employee_data" at [9:21]
What might be the problem?
I'm trying to join two databases. They both have ...
-1
votes
2
answers
38
views
Update a join of two tables based on the third table values
I have three tables.
Table1: Type Table
id |before_id | after_id |
+----+---------------------+
| 1 | 20 | 17|
Table2: History Table
+----+---------+----------+----------+-------------+------...
-1
votes
2
answers
61
views
How to use jq to map values between two large keys containing related data
I am doing curl request and getting response:
{
"data": [
{
"id": "run-12345",
"message": "some message",
"created-by&...
0
votes
4
answers
246
views
Converting SQL query that uses CASE WHEN conditions to construct a column to python
Input:
base_table:
year
category
country
class
2022
English
null
1
2023
English
null
2
2022
English
US
1
2023
Science
null
2
inter_table:
year
country
amount
2022
US
100
2023
US
400
2022
...
0
votes
1
answer
37
views
Create list of column from one table where only ID's from other table have only a 1 value and not 0 from another table
I have a bunch of different tables I'm using to get info on the the products with labels that only have "use" 0 from another label and filtering on the group_id:
CREATE TABLE Product (id, ...
0
votes
0
answers
10
views
Join and fetch in Hibernate Criteria API
I'm currently working on my lab in university. My professor told me to replace long JpaRepository methods (like findXWhereAnd) with Criteria Api. I have multiple entities with different join ...
1
vote
2
answers
50
views
MySQL Joining same table multiple times makes count go weird
Edited to clarify and simplify
I have the following query
select
Signups.user_id,
Count(timeoutTable.user_id) as timeoutCount,
Count(confirmedTable.user_id) as confirmedCount
from Signups
left ...
-1
votes
1
answer
20
views
Question with the result of fj (full join) in DolphinDB
Part 1:
test_fj = fj(t_test_821, t_test, `trade_date `strategy_id `secu_code)
select * from test_fj where trade_date=2019.08.27 and strategy_id=5026
Part 2:
ttt1 = select * from t_test_821 where ...
0
votes
1
answer
47
views
Listagg to get certain values in string and leave other values seperate
I'm trying to get some values from a table into a string and want to leave some out. A different column would determine which values I want in the string and which ones I want to leave out of the ...
1
vote
1
answer
30
views
Basic Join Query Not Yielding All Columns when using "Select *"
I'm taking a SQL Essentials training course. It's time to learn Joins and the instructor is having us use DB Browser. So far, everything has worked great; until this lesson.
The instructor has us make ...
0
votes
2
answers
56
views
kdb/Q How to Union Join two tables, summing a specific value?
I have two tables:
info
First
Last
Score
Full Name
Ann
R
10
Ann R
Bob
C
12
Bob C
Ann
R
13
Ann R
Fil
B
19
Fil B
summary
Full Name
Sum_Scores
Ann R
23
Fil B
19
Bob C
12
The summary table ...