Skip to content

Tag: join

SQL: JOIN vs LEFT OUTER JOIN?

I have multiple SQL queries that look similar where one uses JOIN and another LEFT OUTER JOIN. I played around with SQL and found that it the same results are returned. The codebase uses JOIN and LEFT OUTER JOIN interchangeably. While LEFT JOIN seems to be interchangeable with LEFT OUTER JOIN, I cannot I cann…

Speed up joins on thousands of rows

I have two tables that look something along the lines of: And a query to get data from t1. The query runs fine and takes a few ms to get data from it, although problems start appearing when I use joins. Here’s an example of one of my queries: Which can return a few thousand rows, that might look somethi…

How to add a query to a table in SQL?

I have 3 tables. For simplicity I changed them to these sample tables. table1: CorporateActionSmmary table2# ProductMaster table3# OpenPosition First I need to add ISIN from table2 to table1 table1: CorporateActionSmmary So, I used this code Now as you can see the Quantity is missing in Table1 so I have to ad…

Joining tables based on datetime2 predicate

How do I join tables A and B (see pic) on TripID and where TimeTriggered is between SegmentStart and SegmentEnd? I could try: However since BETWEEN is inclusive on both ends it would join alarm B to both segment 1 and 2. I could try >= AND < but it would leave out alarm C. I could try > AND

Using NVL with JOIN

I want to display 2 values in table but only Student 301 is displayed. Student 102 doesn’t received any grades. I joined two tables. Here’s my query. Thanks for your help Answer Presumably, both students are in enrollment_info. If so, you can use: Note the use of LEFT JOIN. The table where you wan…

Joining table only once in SQL

I’m sure this is very basic, but I’ve hit a brick wall. First post here, long time reader. I’ve got two tables, one is a list of customers, one is a list of their activity by month. For some unknown reason, some of the data in the activity column is duplicated and it’s causing me error…