Wednesday, May 8, 2013

Gap finder

There is some database-relation called "t". It's know that the result of
SELECT x FROM t;
has following form:
a
a+1
a+2
...
a+k1-1
a+k1+1
...
a+k2-1
a+k2+1
...
a+kn-1
a+kn+1
...
a+b-1
a+b
Mind, that ki + 1 < ki+1.

Write SQL query that returns:
a+k1
a+k2
...
a+kn.
Don't use cool features like Postgres generate_series.

No comments:

Post a Comment