Skip to main content
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 ...
this's user avatar
  • 2,039
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) ...
dfhwze's user avatar
  • 14.2k
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 ...
gervais.b's user avatar
  • 2,147
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 <...
ojdo's user avatar
  • 430
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 ...
mikdiet's user avatar
  • 301
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 ...
dfhwze's user avatar
  • 14.2k
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 <...
Jono Brogan's user avatar
3 votes
Accepted

Listing people with their phone numbers (if any)

What you are describing is known asLEFT OUTER JOIN ...
Charles's user avatar
  • 171
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 ...
Eran's user avatar
  • 331
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 ...
rolfl's user avatar
  • 98.1k
2 votes

SQL-style join on arrays using ECMA6

Build an index and use it to map the second array: ...
woxxom's user avatar
  • 2,002
2 votes

Comparing data in SQL using foreign keys

Just think simple: ...
Badaro's user avatar
  • 121
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, ...
aduguid's user avatar
  • 478
2 votes

Mapping key value pairs between two JavaScript objects

It might be a little cleaner to use .reduce instead of for...of... loop: ...
Alex.S's user avatar
  • 159
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 ...
dustytrash's user avatar
  • 2,446
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 ...
Parfait's user avatar
  • 980
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 ...
TinMan's user avatar
  • 4,328
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 ...
Mohrn's user avatar
  • 400
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 <...
Nick's user avatar
  • 156
2 votes
Accepted

Find offers that can be matched with bids

It's hard to see how this could be a performant query. ...
J_H's user avatar
  • 42.2k
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.
alkanstein's user avatar
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 ...
dfhwze's user avatar
  • 14.2k
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 ...
ndp's user avatar
  • 2,381
1 vote

VBA code to import data, doing lookups to detect duplicates

This should be twice as fast: ...
Albert's user avatar
  • 139
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 ...
Vibhav Raghav's user avatar
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. ...
bumperbox's user avatar
  • 2,116
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 ...
Wes H's user avatar
  • 373
1 vote

Inner Join only if satisfies If condition

I did something like this ...
J M's user avatar
  • 119
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): ...
Andrew Ryapolov's user avatar
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 ...
Abel Salgado Romero's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible