select a.snapshot_id, a.param_id, a.param_value from SnapshotParameters a where not exists(select 1 from SnapshotParameters b where b.param_id = a.param_id and b.snapshot_id = 2) and a.snapshot_id = 1 union all select a.snapshot_id, a.param_id, a.param_value from SnapshotParameters a where a.snapshot_id = 2 order by 2