July 2010
Intermediate to advanced
840 pages
16h 33m
English
Mikito Harakiri proposed the problem of writing the shortest SQL query that would return a minimal cover of a set of intervals. For example, given this table, how do you find the contiguous numbers that are completely covered by the given intervals?
CREATE TABLE Intervals (x INTEGER NOT NULL, y INTEGER NOT NULL, CHECK (x <= y), PRIMARY KEY (x, y)); INSERT INTO Intervals VALUES (1, 3); INSERT INTO Intervals VALUES (2, 5); INSERT INTO Intervals VALUES (4, 11); INSERT INTO Intervals VALUES (10, 12); INSERT INTO Intervals VALUES (20, 21); INSERT INTO Intervals VALUES (120, 130); INSERT INTO Intervals VALUES (120, 128); INSERT INTO Intervals VALUES (120, 122); INSERT INTO Intervals VALUES (121, 132); INSERT INTO Intervals VALUES ...
Read now
Unlock full access