Skip to content

Tag: left-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…

Count from 4 tables with join and null values

Tables: What I am expecting to query is this: However this is what I get: With this query: I wonder, in what way the query above could be modified to return the expected results? What would be a good approach to achieve this? Answer You are joining along two dimensions, so you are getting a Cartesian products…

SELECT COUNT from two tables is not working

I have two tables – first table is “projects”: p_id p_name 1 test1 2 test2 3 test2 4 test3 p_name is not unique The second table is “employee”: e_id jan feb mar apr may 1 2 2 3 3 4 2 1 1 3 3 2 3 1 3 2 3 3 4 4 3 2 3 4 I’d like