Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

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)
Source by sqlfiddle.com #
 
PREVIOUS NEXT
Tagged: #sql #gap #missing #values
ADD COMMENT
Topic
Name
2+9 =