SELECT * FROM ( SELECT x, (SELECT min(x) FROM my_table t2 WHERE t2.x > t.x) next_x FROM my_table t ) WHERE x <> next_x - 1; /* if my_table contains for x: 1 2 5 6 7 10 X NEXT_X 2 5 7 10 */ -- ⇓ Test it ⇓ (Fiddle source link)