Denis Burke wrote: > The SQLite documentation (http://www.sqlite.org/lang_select.html) says the > GROUP BY clause accepts [expr]. And [expr] can be composed of a literal. > What I cannot find is what SQLite does (or should do) with a literal in the > GROUP BY clause.
SQL-92 doesn't allow it: | Each <column reference> in the <group by clause> shall unambiguously | reference a column of T. But ORDER BY supports referencing columns by their index: | If a <sort specification> contains an <unsigned integer>, then the | <unsigned integer> shall be greater than 0 and not greater than the | degree of T. The <sort specification> identifies the column of T | with the ordinal position specified by the <unsigned integer>. SQLite extends GROUP BY to also allow this kind of column references. > In the case of string literals, I would have expected to see all rows > returned and in these cases the group by become effectively a no-op. | The result of the <group by clause> is a partitioning of T into | a set of groups. The set is the minimum number of groups such | that, for each grouping column of each group of more than one | row, no two values of that grouping column are distinct. If we say that the "value of the grouping column" is the value of the expression itself, then the query must result in a single group because no two values are distinct in this column in any of the rows. Regards, Clemens _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users