Questions tagged [join]

A SQL JOIN clause combines records from two or more tables in a relational database.

Filter by
Sorted by
Tagged with
2
votes
1answer
60 views

join and pivot multiple tables of securities data in mysql

I'm interested in a way to join three (or more) tables in a way that is more efficient (both in terms of conciseness of code and in terms of generating the results) than what I have currently. ...
1
vote
1answer
15 views

MySQL GROUP BY id, then show name

I have a users table where some users have the same name: ...
2
votes
1answer
46 views

Python script to find employees who are in one PostgreSQL table but not in another

I'm writing a python script and do database query to get the ids of employees who are in one table but are not in another. I'm using psycopg2 module for python 2 and PostgreSQL as database. After ...
4
votes
1answer
178 views

SQL query to count loans issued during each week

Calculate the number of loans issued by the Regional offices for each business week in the period from 38 to 40 business week of 2011 inclusive. Sort by name of the regional unit, business week. ...
5
votes
1answer
34 views

Merging client names into orders using RxJS

I have an API which I can't modify. I have to use data as it is. I want to join data from two separate requests where the second request is based on data from the first one. I have a working ...
1
vote
1answer
47 views

Query to generate payroll based on attendance for a month

I have written a query to generate payroll based on attendance for a month, for about 4000 employees. It takes quite a long time to execute. Basically, what I am doing is to joining two different ...
3
votes
2answers
151 views

VBA code to import data, doing lookups to detect duplicates

I have an import macro, which creates ID by concatenating cells, then I compare using VLOOKUP with another sheet if any duplicate found. It's running very slowly, so I want to know better ways to ...
1
vote
1answer
66 views

Merging records from one spreadsheet into another

I have created the code below that compare two spreadsheets . It initially compares the range of value from sheet1 ("Status") to sheet2 ("Interface") . Whenever a range matches with the ranges present ...
1
vote
1answer
37 views

Listing people with their phone numbers (if any)

I have the following tables in my database: ...
1
vote
1answer
189 views

Simple join between 2 tables with unusual structure

I have two tables as below ACCOUNTS: ...
2
votes
1answer
94 views

Conditional joining Pandas dataframes

I'm looking for an optimum way to join two Dataframes where the same record exists in both. Examples would be: ...
3
votes
0answers
72 views

Sequential master update

I'm creating a version of the classic sequential master file update in java. This is used when you sort two files by the same key for updating one file with the other. In this case, I'm pulling in all ...
1
vote
0answers
23 views

SQL self-join to label nodes on binary search tree

Would like feedback on my SQL (1) efficiency and (2) readability, and if the conditions I featured in my CASE statement could be transferred to a join, etc. Here'...
3
votes
1answer
84 views

Project management query for various organizational units

I use the code below to calculate the required information from other tables. I used joins to display names instead of IDs and to get required sums from other tables. I used ...
2
votes
1answer
52 views

Joining tables by skipping the intermediate parent table [closed]

We've tables adm_app, quals_data to which personal_data is a parent table. We are retrieving ...
2
votes
1answer
46 views

Comparing data in SQL using foreign keys

The following is given: ...
0
votes
1answer
204 views

T-SQL query outer apply with nested subqueries

I have the following 3 tables, and I don't have the option to modify them. [Logs] table with [log_type], ...
2
votes
1answer
41 views

Inner Join only if satisfies If condition

I'm looking for code review, and optimizations. I have two tables ItemCategory and ShopItemCategory ItemCategory ...
3
votes
4answers
3k views

Java8: Stream filter, map and joining with an alternative result if the stream is empty

Given a list of integers, I would like to: filter odds numbers produce a list inside brackets: [n1, n2, n3] if the list is empty it should be a dash ...
3
votes
1answer
696 views

Mapping key value pairs between two JavaScript objects

I have two JavaScript objects: ...
1
vote
1answer
43 views

Listing blog posts, each of which may belong to multiple categories

I have 3 tables like this: ...
3
votes
1answer
1k views

Joining WorkTypes to WorkGroups via Channels and Users to check authorization

I need to select some "work types" from a channel. These "channels" are in "work groups" and both channels and work groups need to have permissions to view them (tables are ChannelUsers and ...
1
vote
2answers
75 views

SQL-style join on arrays using ECMA6

I have a code snippet which performs an SQL-style join on objects in two arrays based on a specific field (in the code below, .id). ...
7
votes
3answers
219 views

Linking two databases based on street addresses

For my work, I wrote a python script to link 2 files. Since I am an autodidact and since no one of my colleagues writes code, I ask the question here. My code takes an unbelievable time to run. Is it ...
0
votes
1answer
103 views

MySQL query to select messages related to a user

Could someone please check my query and the table structures and let me know if there is any way to improve it. I would like some tips for my own personal development Query in PHP: ...
7
votes
1answer
73 views

Joining a product-application-customer relationship using Java 8 Streams

I have three classes: product, customer and application. The schema of these classes are as follows: ...
1
vote
1answer
2k views

Selecting employees in certain departments using LINQ

I am trying to select the DepartmentName from Employee Table based on where condition. Is any way to simplify the code? ...
4
votes
1answer
54 views

Counting penalties for each player by joining tables, where some of the data is null

I have a table full of player names: I also have a table full of player penalties: I have to list all of the players names, player numbers, and the number of penalties that they've incurred. To do ...
1
vote
1answer
57 views

Select sum from latest values in table

...
4
votes
2answers
142 views

Loading objects for users, roles, and groups from a query with LEFT OUTER JOINs

I have this function that returns me a list of users with their roles and groups. As you can see, this is how I fetch and create list of objects. I'm wondering whether this is a good approach and what ...
1
vote
0answers
172 views

Join via navigation properties with collection

There are some related collection objects in my table and I'm trying to get list with joining this tables. But this code is seems bad: Entities that shortened: User: ...
2
votes
0answers
37 views

Counting items that have a matching attribute

Here is my code which is going to through multiple for loops to get the matching product attribute. I have single product with attributes trying to find out the ...
7
votes
4answers
449 views

Using LINQ to group social networking links for each user

I have a model named User. Each user can have some social links. Now I want to get all users with their social link as a single row in the result. Here are my ...
3
votes
1answer
48 views

Acquiring earnings information

The first part of the query grabs Policy's Premiums, Effective and ...
4
votes
2answers
108 views

Matching maximal nodes with velocities

I have written a code which works very good for small data-files (see below). The data file 'WSPL.dat' which I want to evaluate has a size of 2.6 GB and the data file 'VELOC.dat' has a size of 4.3 GB....
3
votes
1answer
80 views

Gather information about computers from multiple CSV files

I created a script to import several CSV files from various sources and one CSV file with a list of systems in it. the script searches each CSV file to see if the system exist in the file and if it ...
2
votes
1answer
869 views

Cross context joins in .NET

This is how I made a cross context join. What do you think? How would you do this better? ...
1
vote
1answer
55 views

Rails query for all questions in tournaments that a user participates in

I'm new to rails and this is the situation I'm in: I have a User model that has many tournaments, a Tournament has many users ...
6
votes
1answer
4k views

Python search for array in large text file

I asked similar question at: https://stackoverflow.com/questions/38410982/superfast-regexmatch-in-large-text-file ...
3
votes
1answer
62 views

Filling in gym membership prices by joining PANDAS dataframes

I have two dataframes, df which contains a list of members in addition to the type of contract that they purchased on a given date, ...
3
votes
1answer
63 views

Get title from database based on member country

I asked this question before. However, I realized that I had to edit some of my code after I got good answers. Therefore, I'm asking a new question here. I have the following database: Each member ...
0
votes
1answer
78 views

Load title from database based on member country

As tim suggested, some changes to the database was necessary. I have posed an improved version of this question at Get title from database based on member country. I have the following database: ...
8
votes
2answers
19k views

Extracting values from dictionaries where the keys match

I have two Dictionaries with around 65,000 KeyValuePairs each. I used foreach and if-else statements to compare them and get values, but it goes very slow. How could I optimize my code and gain more ...
1
vote
1answer
39 views

Mapping discussion entries from an SQL-View to objects

In my ASP.NET MVC application, I am loading Discussion Entry records along with User info (who posted the entry), Badges (assigned to the entry), Reactions (made to the entry like Facebook-style ...
4
votes
1answer
26 views

SQL report of subscribers and their associated revenue

A user can have many subscriptions, and a subscription belongs to one plan. The plans table tells us a subscription's cost. Is the query below the correct one for ...
4
votes
1answer
1k views

Joining huge CSV files and splitting the result into batches

I've got ~20GB of data about the same subject, concatenated from small files of 16kB, each produced by different measurement equipment. They share some headers (on the example: B, D & E) and they ...
3
votes
0answers
34 views

Updating ActiveRecord with text from a joined table

I have an Active Record update with the following data model: TvMenuProfile has one rich_text_special ...
30
votes
6answers
6k views

Counting rows in a CSV file that correspond to a database row, each with a million records

I have two DataTables: dt: is populated from a CSV file with over 1.7 million rows dataStructure.Tables["AccountData"]: is ...
2
votes
1answer
31 views

Collating client ratings

The code is fetching records from a table called CSAT_SUMMARY_REPORTS[driver table] but due to the filters conditions applied which needs to be checked in another ...
6
votes
1answer
130 views

Report for a restaurant showing hourly sales information for a given timespan

I have been tasked with creating a report for a high-volume restaurant that shows hourly sales information for a given timespan. When generating this report for a single day, it's very quick, but when ...