Jay A. Kreibich <[email protected]> wrote:
> On Fri, Jun 11, 2010 at 11:30:43AM +0200, Benoit Mortgat scratched on the 
> wall:
> 
>> select col1, col2 from foo group by col1;
>> 
>> As you can see, that last query does not result in any error, however
>> col2 should not be selectable if not in the group by clause?A
>> 
>> Is this a feature, a known bug or an unknown one? If this is a
>> feature, is there a pragma to forbid such a syntax?
> 
>  While the results are not all that useful, there is nothing that says
>  you can't do this.  You can't outright prohibit non-GROUP BY column
>  references in the select header, since they can be passed to
>  aggregate functions.

Well, many SQL engines, as well as SQL-92 standard, do prohibit such a syntax. 
According to the standard, in a statement using GROUP BY, any column reference 
that appears in SELECT clause must also appear in GROUP BY clause or be part of 
an argument of an aggregate function. SQLite allows "naked" non-grouped columns 
as an extension (which is occasionally useful).
-- 
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to