On 8/4/14, Mark Lawrence <no...@null.net> wrote:
> I try to remember to define GROUP BY values when using aggregate
> functions (and I wish SQLite considered it an error otherwise) but I
> forget once and the result surprised me.
>
> It is expected behaviour that a row is returned in this situation even
> through the tables are empty?  Adding a "GROUP BY x.id" returned the
> expected empty set.

This is the behavior I expect from the documentation.

Specifically, the documentation for the SELECT statement at
"http://sqlite.org/lang_select.html"; says

> If the SELECT statement is an aggregate query without a GROUP BY clause, then 
> each aggregate expression in the result-set is evaluated once across the 
> entire dataset. [...] Or, if the dataset contains zero rows, then each 
> non-aggregate expression is evaluated against a row consisting entirely of 
> NULL values.
>
> [...] An aggregate query without a GROUP BY clause always returns exactly one 
> row of data, even if there are zero rows of input data.

--
Ambrus
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to