6
votes
Accepted
Joining WorkTypes to WorkGroups via Channels and Users to check authorization
I am understanding that your goal is to return a set of data that a user is authorized to see. I further understand that ChannelUsers and ...
5
votes
Accepted
SQL query to count loans issued during each week
Your query could be simplified.
use inner join to avoid ambiguity when reading the query
temporal interval join date between start and end (inclusive end)
...
4
votes
Java8: Stream filter, map and joining with an alternative result if the stream is empty
You can use reduce, it returns an Optional that is empty if the stream is empty. You can use ...
4
votes
Accepted
Conditional joining Pandas dataframes
This is the textbook example of an inner join. The most canonical way to have your id columns being used for the matching, set them as an index first (here using <...
3
votes
Accepted
Update join table using list of checkboxes in Rails
Actually, Active Record can work with joined collection (including has_many :through) from the box.
So, you just need to pass new collection instead of old, and AR will delete excessive and add new ...
3
votes
Accepted
Join and pivot multiple tables of securities data in MySQL
DB Design
Your tables are not correctly normalized:
codes.description depends on codes.code → requires a table with ...
3
votes
Accepted
Python script to find employees who are in one PostgreSQL table but not in another
LEFT JOIN from test_test to test_table selecting only rows where test_table.test_emp_id is <...
3
votes
Accepted
Listing people with their phone numbers (if any)
What you are describing is known asLEFT OUTER JOIN
...
3
votes
Java8: Stream filter, map and joining with an alternative result if the stream is empty
If you want to still rely on Collectors.joining (and not implement that logic yourself), you can simply add a ...
3
votes
Accepted
Joining tables by skipping the intermediate parent table
Your changes to the query are good changes.
Just because the both adm_app and quals_data have the same child relationship to ...
2
votes
2
votes
2
votes
Accepted
Project management query for various organizational units
I'd use common table expressions (CTE) for COSTS, EXPENSES and DURATIONS tables. In the CTE, ...
2
votes
Mapping key value pairs between two JavaScript objects
It might be a little cleaner to use .reduce instead of for...of... loop:
...
2
votes
Simple join between 2 tables with unusual structure
You should probably fire the Database Admin.
But seriously, a problem in your query arises if you have duplicate, but different (bank_id + branch_id)'s. For example, (22 + 202) and (2 + 2202) both ...
2
votes
Query to generate payroll based on attendance for a month
Without specific explain plan details, consider these broad stroke recommendations. Currently, I do not see how UNION fits into your needs as you are essentially ...
2
votes
Accepted
Merging records from one spreadsheet into another
The unique data could be appended, using a Scripting Dictionary and arrays in less than a second. Alternatively, you could use an ADO Query to append records from sheet1, not in sheet2.
The easiest ...
2
votes
Accepted
Finding optimal mapping patterns that transform relational data into a linear format
Some slight improvements:
You could do without the result array (less state 🙌).
I think using vanilla object destructuring is more clear than the lowdash ...
2
votes
Accepted
Keeping only maximum date rows in a group
You can use ROW_NUMBER to rank your data according to date for each combination of id and <...
2
votes
Accepted
Find offers that can be matched with bids
It's hard to see how this could be a performant query.
...
1
vote
Accepted
Flask Database Design with ORM
At the end of the day I used pandas.
df = pandas.read_sql_query("""My join query""")
This all just solved my problem.
1
vote
Accepted
MySQL GROUP BY id, then show name
If you don't want to use a subquery, you can include the second table with a join before the group by:
SQL Fiddle
...
1
vote
Merging client names into orders using RxJS
Looks good. Yeah, sometimes APIs are hard to work with.
Instead of the loop clientsData.forEach, you might want to reduce the client data down to an object, where ...
1
vote
1
vote
SQL self-join to label nodes on binary search tree
This solution will work only on the dataset that you've mentioned. If you apply this code to another dataset it will throw up erroneous results.
Here is why:
Condition ...
1
vote
Accepted
Listing blog posts, each of which may belong to multiple categories
I am not sure why you are using 2 foreach loops, you should be able to combine them.
...
1
vote
Accepted
T-SQL query outer apply with nested subqueries
Here is an attempt, though I can't verify it works because you didn't provide insert scripts and didn't include the ID column in the DDL. You also don't mention if log 1/7 is only considered for the ...
1
vote
1
vote
Java8: Stream filter, map and joining with an alternative result if the stream is empty
Improving StringJoiner solution (that is way-more efficient than String concatenation):
...
1
vote
Java8: Stream filter, map and joining with an alternative result if the stream is empty
Just for the sake of showing a different approach, and answering your tweet https://twitter.com/j2r2b/status/943163833975177216.
With a custom Collector and StringJoiner. You can convert the Integer ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
join × 92sql × 43
performance × 27
mysql × 24
c# × 11
sql-server × 11
python × 9
php × 9
database × 8
javascript × 6
csv × 6
t-sql × 6
java × 5
vba × 4
time-limit-exceeded × 4
json × 4
linq × 4
mysqli × 4
beginner × 3
excel × 3
pandas × 3
ruby-on-rails × 3
active-record × 3
array × 2
ruby × 2