Why Does a LEFT JOIN Report Lose Projects With No Matching Activity?

A manager asks for every project and its completed activities. After a filter is added, projects without completed activities disappear. The report looks cleaner, but it no longer answers the original question: which projects have nothing completed?
A LEFT JOIN can preserve unmatched projects, yet a later condition can remove them. Review where the condition acts and what population the report promises to include. The important decision is whether the condition defines a matching activity or eligibility for the final report.
Describe the population before the activity rule
Write the population first: all projects in the selected portfolio. Then describe the attached information: activities whose status is completed. These are two separate statements.
If the real question is instead projects that have completed activity, the population is different. That report may legitimately exclude projects with none. Avoid changing between these meanings simply to make a query return fewer blank cells.
Locate the filter in the query
PostgreSQL's table-expression documentation demonstrates that restrictions in an outer join's ON condition can produce different results from restrictions in WHERE. ON determines matching rows; WHERE filters the result after the join.
For this example, a condition requiring the activity status to equal completed in WHERE excludes the null-extended rows representing no match. Keeping that activity restriction within the join condition can retain the parent project while showing no qualifying activity.
This is a specific review of outer-join behavior, not a rule that every filter belongs in ON. A condition limiting the portfolio itself may properly determine which projects enter the report.
An illustrative three-project fixture
Project Birch has one completed activity. Project Cedar has one planned activity and no completed activity. Project Elm has no activity records. The requested report includes all three projects, showing qualifying activity only for Birch.
Test Cedar separately from Elm. A proposed fix that allows a null activity identifier in WHERE may preserve Elm while still losing Cedar, because Cedar matched a planned activity before the later filter rejected it. Testing only a project with no activity records would miss that problem.
Write the expected output before executing
List the three project identifiers and the expected activity identifier, or the absence of one, for each. Include a second completed activity for Birch in another fixture to expose multiple matches.
Decide whether the report wants one row per project or one row per qualifying activity. Preserving all projects does not prevent multiple activity rows from expanding the result. That is a separate aggregation decision, and it needs its own expected output.
Distinguish absence from a measured zero
A missing activity match should not silently become evidence that work took zero minutes. If the display needs a count of completed activities, define and calculate that count. If it displays a completion duration, show the absence appropriately.
Have a business reviewer explain what an empty value means. The query author and report reader should agree whether it signals no qualifying record, an unknown attribute, or an unavailable source. Those meanings can require different follow-up actions.
Review changes with traceable cases
Compare the old and proposed reports using the same input snapshot. Identify projects added or removed and explain each difference. A change in row count is useful evidence, but it does not tell you whether the right projects were restored.
Record the filter location, the parent population, and the treatment of projects with only nonqualifying activity. Retain these examples as acceptance cases for future query edits. They are more informative than a screenshot of a plausible dashboard.
Finish with a population statement
A useful report note says that all selected projects are included, even when no completed activity exists. It should also explain whether multiple activities produce multiple rows or a summary.
The review is complete when Birch, Cedar, and Elm each appear exactly as the stated business question requires. The SQL keyword alone is not the guarantee; the verified population is.
Continue with Why Did a Report Total Increase After Adding a Detail Table? for the related planning decision.
The published FutureOS introduction describes the project as being in prelaunch. Use this guide to prepare a concrete project discussion; it does not announce an available FutureOS feature.
Prepared with AI assistance. Primary sources checked on October 25, 2026. Examples and procedures are illustrative editorial guidance, not FutureOS product announcements or an independently reviewed assessment.



Comments