Right you are, thank you! Regards, Tobias
-----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Ivan Shmakov Sent: den 31 augusti 2011 10:13 To: [email protected] Subject: Re: [sqlite] max() with LIMIT >>>>> Tobias Vesterlund writes: [...] > If I do SELECT max(id) FROM t; it will return 99. > If I do SELECT id FROM t WHERE id > 0 LIMIT 10; it will return > > 1,2,3,4,5,6,7,8,9,10 > But If I do SELECT max(id) FROM t WHERE id > 0 LIMIT 10; it will > return > 99. > My logic, which may be flawed in this case, tells me the third SELECT > > should return 10 and not 99. LIMIT applies /after/ the aggregation. Consider, e. g., using GROUP BY, and then selecting no more than 10 groups' maximums. > Is it possible to get the highest value in a "limited column" when > using > LIMIT? Sure. SELECT max (id) FROM (SELECT id FROM t WHERE id > 0 LIMIT 10); -- FSF associate member #7257 Coming soon: Software Freedom Day http://mail.sf-day.org/lists/listinfo/ planning-ru (ru), sfd-discuss (en) _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

