Yes, the max(y) operation is flattened out of the query probably because it is not referenced anywhere and the optimizer does not see that it is performing any useful function. There is still only one row returned, however, because the same accumulator is used to collect the result, it just operates on all rows instead of only those which set the max() return value.
>-----Original Message----- >From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users- >boun...@sqlite.org] On Behalf Of Lea Verou >Sent: Saturday, 13 September, 2014 22:19 >To: sqlite-users@sqlite.org >Subject: [sqlite] BUG: Aggregate functions in subqueries > >Per the 3.7.11 changelog [1], queries of the form SELECT max(x), y FROM >table return the value of y from the same row that contains the maximum x >value. However, this: > >select y from (SELECT max(x), y FROM table); > >would not return the same y rows. This would work as expected: > >select m, y from (SELECT max(x) as m, y FROM table); > >[1]: http://www.sqlite.org/changes.html#version_3_7_11 >_______________________________________________ >sqlite-users mailing list >sqlite-users@sqlite.org >http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users