Answers for "sql gap missing values"

SQL
0

sql gap missing values

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)
Posted by: Guest on May-09-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language