On 25 Apr 2013, at 4:23pm, Jay A. Kreibich <[email protected]> wrote: > Except there is no such thing as "GROUP BY order". SQL Golden Rule: > If there is no ORDER BY, the rows have no order. According to SQL, > neither the groups, nor the rows within a group (as they are fed into > aggregates) have a defined order. Any query that makes assumptions > about the ordered result of a GROUP BY is broken. > > Use the out-of-order index.
GROUP BY on multiple columns means that the values in all those columns have to be the same for the rows to be included in the same GROUP. It says nothing about the order those groups should appear in in the results of the SELECT. Okay. So adding this to what went by upthread, I was wrong. Column order in the GROUP BY clause doesn't matter. Therefore the upthread comment that GROUP BY A,B means exactly the same as GROUP BY B,A is correct. So if there's an index which features those columns in any order it can be used, not matter what order the columns appear in in the GROUP BY clause. So it was perfectly reasonable for the OP to wonder why an index was used for one order but not another. Simon. _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

