SQLite Forum

LEFT JOIN Misunderstanding
Login
Here's concrete suggestion (you don't have to go with this one of course).

This is as similar to what you have as possible with a little extra indenting to reveal structure.

```
WITH LastEntries (ProjID, pl_insert, pe_insert)
AS
(
  SELECT projid,
         max(InsertDate),
         (SELECT max(insertdate) FROM project_extras where projid = e.projid)
    FROM project_list e
    GROUP BY projid
 )
SELECT count(c.CreatedDate) AS Aug, a.Project_Type , a.ProjID
FROM Project_List AS a
  LEFT JOIN Project_Extras AS b
    ON a.ProjID == b.ProjID
    AND
       b.FinCarryOver != 'y'
    AND
       b.MonthlyRpt = 'y'
    AND
       b.BudgetYear = '2021'
  LEFT JOIN Project_Highlights AS c
    ON b.ProjID = c.ProjID
    AND 
       c.CreatedDate LIKE '2021-08%' 
  LEFT JOIN LastEntries AS f
WHERE
    a.Project_Delivered != 'Yes'
  AND
    a.PMO_Board_Report != 'No'
  AND
    a.Status == 'Acknowledged'
  AND
    a.InsertDate = f.pl_insert
  AND
    b.InsertDate = f.pe_insert
  AND
    a.ProjID = f.projid
GROUP BY a.ProjID
ORDER BY a.Manager, a.ProjID
;
```