Ivan Krylov wrote:
> select * from test where id in (1,2) group by id;

Please note that this is not standard SQL; SQLite allows to SELECT
columns that are not mentioned in the GROUP BY clause, but they get
their values from a random row in the group.
<https://www.sqlite.org/lang_select.html#bareagg>

> but then I don't get to control which source I'm obtaining the values
> from (when there is more than one). Let's assume for now that I prefer
> to choose values with a particular source_id, but if those are not
> present, I would take what's available.

There is another SQLite extension which allows to select a row in the
group by using MAX() or MIN():

  select *, min(abs(source_id - 3)) from test where id in (1,2) group by id;


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to