Hi Christoph,

the id column does not appear in an aggregate function and also not in group by.

Your statement uses 'GROUP BY Name' and so returns exactly one row per name. If there are several rows with the same name, the ID of your result is from one of these rows. The appropriate documentation is

"Each expression in the result-set is then evaluated once for each group of rows. If the expression is an aggregate expression, it is evaluated across all rows in the group. Otherwise, it is evaluated against a single arbitrarily chosen row from within the group. If there is more than one non-aggregate expression in the result-set, then all such expressions are evaluated for the same row. " from here http://www.sqlite.org/lang_select.html#resultset

The keyword here is "arbitrarily chosen".

So, you can not expect to get the same id every time even if you do not change the sqlite version.

Hope this helps
Martin

Am 22.08.2014 15:19, schrieb Christoph Wiedemann:
SELECT Id, Name, MIN(Score) AS Score FROM Test GROUP BY Name ORDER BY Score

--

*Codeswift GmbH *
Kräutlerweg 20a
A-5020 Salzburg
Tel: +49 (0) 8662 / 494330
Mob: +49 (0) 171 / 4487687
Fax: +49 (0) 3212 / 1001404
engelsch...@codeswift.com
www.codeswift.com / www.swiftcash.at

Codeswift Professional IT Services GmbH
Firmenbuch-Nr. FN 202820s
UID-Nr. ATU 50576309

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to