Re: [sqlite] Choosing one value from the group with priority

2019-02-12 Thread R Smith
On 2019/02/12 7:29 PM, Ivan Krylov wrote: I can supply a list of source_ids in order of decreasing priority from an array in my application, though I lose cross-database portability (is there a portable way to pass an array to a parameterized query, though?)... There is no fully portable

Re: [sqlite] Choosing one value from the group with priority

2019-02-12 Thread Ivan Krylov
On Tue, 12 Feb 2019 13:31:59 +0100 Clemens Ladisch wrote: > 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. Thank you for pointing this out! I was aware of the row being random when selected this way, but

Re: [sqlite] Choosing one value from the group with priority

2019-02-12 Thread Ivan Krylov
On Tue, 12 Feb 2019 14:08:20 +0200 R Smith wrote: > The semantics are made more legible using a CTE here, but can be > done without it. The essential difference is that it uses a sub-query > to obtain the minimum priority as opposed to introducing a sub-table > sort. Thank you for your reply!

Re: [sqlite] Choosing one value from the group with priority

2019-02-12 Thread Clemens Ladisch
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.

Re: [sqlite] Choosing one value from the group with priority

2019-02-12 Thread R Smith
On 2019/02/12 1:13 PM, Ivan Krylov wrote: Hi! I have a table of some values obtained from different sources: create table test ( id, source_id, value, primary key(id, source_id) ); insert into test values (1, 1, 11), (1, 2, 12), (1, 3, 13), (2, 1, 21),

[sqlite] Choosing one value from the group with priority

2019-02-12 Thread Ivan Krylov
Hi! I have a table of some values obtained from different sources: create table test ( id, source_id, value, primary key(id, source_id) ); insert into test values (1, 1, 11), (1, 2, 12), (1, 3, 13), (2, 1, 21), (3, 2, 32); When SELECTing the values, I