If the real schema is as simple as the example you could use SQLite's [bare columns in aggregates](https://www.sqlite.org/quirks.html#aggregate_queries_can_contain_non_aggregate_result_columns_that_are_not_in_the_group_by_clause) to get the highest snapshot for each parameter. Something like... ` select max(snapshot_id) as snapshot_id, param_id, param_value from SnapshotParameters group by param_id order by param_id; `