Gillman, David <dgill...@akamai.com> wrote: > Is this behavior known? The third query returns no rows even though bar = 1. > > sqlite> select ind, sum(foo) foo, sum(bar) bar from (select 1 ind, 0 foo, 1 > bar union select 1 ind, 1 foo, 0 bar) group by ind > having foo > 0; > ind|foo|bar > 1|1|1 > sqlite> select ind, sum(foo) foo, sum(bar) bar from (select 1 ind, 0 foo, 1 > bar union select 1 ind, 1 foo, 0 bar) group by ind > having bar > 0;
Your condition involves an expression that neither appears in GROUP BY clause, nor uses an aggregate function. The value of foo (in the first query) and bar (in the second) will come from some row in the group - it is undefined which one. Purely by accident, SQLite chose the row that satisfies the condition in the first case, and one that doesn't in the second. -- Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users