Sometimes a correlated aggregate subquery which references an outer table will cause the outer query to behave like an aggregate query. Unfortunately this is not a bug - it's just the way it is. This behaviour is consistent with the way other DB engines behave. See [https://sqlite.org/forum/forumpost/9f2b929904329af5](https://sqlite.org/forum/forumpost/9f2b929904329af5)