43,856 questions
0
votes
1
answer
125
views
Make MySQL evaluate subquery first
SELECT tt.trans_type_name AS transaction_type,
trans.transaction_time,
a.trans_action_name AS transaction_action_name,
trans.transaction_notes
FROM(SELECT Cast(...
0
votes
0
answers
36
views
Pandas merge on one of two criteria [duplicate]
I have a table/df that holds a set of code and value pairs. The codes are a mix of old (legacy) and new codes due to process changes. I have a second table/df that holds the old codes, new codes, ...
5
votes
4
answers
206
views
UPDATE with LEFT JOIN and condition IS NULL
I have the following table definitions:
Table public.messages:
Column
Type
Collation
Nullable
Default
ip
text
msg
text
ignore
boolean
Table public.host:
Column
Type
Collation
Nullable
Default
ip
text
...
2
votes
1
answer
125
views
Find differing rows between two Polars DataFrames based on ID and multiple columns
I have two Polars DataFrames (df1 and df2) with the same columns.
I want to compare them by ID and Iname, and get the rows where any of the other columns (X, Y, Z) differ between the two.
import ...
2
votes
1
answer
61
views
How to join a pivoted table with other tables
I’m working with the DolphinDB Python API to analyze financial data, but I can’t join a table transformed by pivotby() with another table directly. The error says TablePivotBy has no merge attribute. ...
2
votes
0
answers
82
views
Join API endpoints and write out result
I would like to join endpoints and return result (in Wordpress). After I get the results, I want to import with WP All Import plugin, Hotels and Locations. I'm using Traveler theme.
The API is: https:/...
2
votes
2
answers
126
views
R data.table rolling join with limit window in number of data points
dates = as.Date(c('2000-01-01','2000-02-01','2000-03-01','2000-04-01'))
dt = data.table(date = dates[1:2], value = c(1,2))
> dt
date value
<Date> <num>
1: 2000-01-01 ...
2
votes
1
answer
103
views
SELECT query over 4 tables including MAX function in JOIN
I have 4 tables in a mysql database:
Results
Result_ID
Season_ID
1
1
2
1
4
2
4
2
…
…
37
5
38
5
Players
Player_ID | Player | Player_Type | Player_Order
1 Fred Defender-Left 1
2 ...
2
votes
3
answers
146
views
How to left join two datasets in r based on several conditions? [closed]
I have two datasets (Each dataset around 1.8M rows), one contains per second data, and the other one sometimes have per second, every two second, or three second. I wanted to join these two datasets, ...
1
vote
3
answers
112
views
Retrieving data from another table after using MIN function
I have the following query to pull the oldest batch we have shipped today:
SELECT
TO_CHAR(PT.CREATE_DATE_TIME, 'MM/DD/YY'),
PT.ITEM_ID,
MIN(PT.BATCH_NBR)
FROM
PIX_TRAN PT
WHERE
PT.TRAN_TYPE = ...
0
votes
2
answers
158
views
MariaDB left join ignores index key - slow performance with large joined table
I have a select with a large joined table. On local, performance is fine, but on my server it takes much longer. Below are the version infos (I just upgraded to MariaDB 11.4 on the server).
If I do an ...
0
votes
0
answers
40
views
Ways to support joins on elasticsearch
I'm working with two Elasticsearch indexes -> accounts and contacts. These indexes are related in such a way that each account can be associated to contacts. However, not all contact data is ...
-1
votes
2
answers
79
views
SQL code for identifying salary for a status
I have 2 tables:
DEPT:
dept_no
C
N
1
200
100
2
300
150
3
400
200
and EMP:
dept_no
employee_no
Task_status
Salary
1
1
C
1
2
N
2
1
C
2
2
C
with column Salary has to be calculated. Task status is C is ...
2
votes
3
answers
125
views
join subquery return multiple rows
I have main query:
SELECT mt.media_id, mt.title,
SUM(DISTINCT sht.share) as share_count
FROM $grouped_media_table mt
LEFT JOIN $share_table sht ON sht.media_id = mt.media_id AND sht.title = mt....
1
vote
1
answer
56
views
Create new pyspark data frame from two joined data frames
I want to save the result of two joined dataframes in pyspak in a third, new dataframe.
When I assigned the joined dfs to a variable, its class is NoneType, and what I need is a dataframe.
mappedhh = ...
0
votes
1
answer
59
views
Why does PostgreSQL scan a joined table with a foreign key reference to a primary key when it is not logically part of query? [closed]
I am trying to understand why the behavior queries which logically only involve a primary key from one table perform a scan on a referenced foreign key in a joined table. Logically I see no reason ...
4
votes
2
answers
102
views
SQL join - transform row into column
I'm trying to execute a SQL query to transform some rows into columns. The problem: I have more rows at the end.
Example: I have only one table in Postgres.
id
account
category
sub_category
jsondata (...
1
vote
1
answer
60
views
Combine two pandas Dataframes with Timestamp Index
I have two dataframes with timestamp data. It is sensor readouts from different sources.
I want to combine them. The left dataframe (df1) can be quite large as it will be a combination of multiple ...
0
votes
3
answers
118
views
Teradata SQL Conditional Join
I'm guessing my question was asked before, but after hours of scouring, either I'm not able to figure out how the answers match my dilemma or it truly hasn't been asked (I'm guessing the former). So, ...
2
votes
1
answer
32
views
Control Spark Join Hash Partitioning
I have three dataframes A, B, and C.
I need to join dataframes A and B on columns [a, b] and dataframes A and C on columns [a, c].
I would like to force Spark to only hash-partition the three ...
0
votes
0
answers
15
views
Ambiguous column when joining table using createQuery
In my database all tables have key Id. How should I join tables correctly?
For example, right now I'm trying to join the Users and Companies tables like this:
export class UserService<ServiceParams ...
-1
votes
2
answers
66
views
Multi-column catch-all join with 'ND' wildcard across 4 columns
I'm trying to join a large fact table (~100M rows) to a dimension table (~500K rows) using 4 columns as composite keys. In the dimension table, each of the 4 join columns may contain the value 'ND', ...
0
votes
1
answer
68
views
SQL join large table with only select columns from two other tables
I want to join three tables (with many columns each).
From the first table I need all columns.
From the second and third table I only need a few columns each.
How can I join the three tables without ...
2
votes
3
answers
96
views
Find pairs of keys for rows that have at least one property in common
I'm using polars with a data frame whose schema looks like this:
Schema({'CustomerID': String, 'StockCode': String, 'Total': Int64})
interpreted as "Customer CustomerID bought Total of product ...
-1
votes
1
answer
65
views
mysql join return all records from left table
table comment report
CREATE TABLE $comment_report_table (
`comment_id` int(11) unsigned DEFAULT NULL,
`user_id` int(11) unsigned DEFAULT NULL,
`reason` varchar(100)...