After some testing, I came up with the following SQL statement:
SELECT date, itemName
FROM "Table" as t1
WHERE NOT EXISTS (
SELECT date
FROM "Table" as t2
WHERE t2.date = (t1.date - INTERVAL '1 day')
)
ORDER BY date
OFFSET 1
This will give you all the lines that do not have a direct successor.
If you change the instruction:
SELECT date, itemName
FROM "Table" as t1
WHERE NOT EXISTS (
SELECT date
FROM "Table" as t2
WHERE (t2.date >= (t1.date - INTERVAL '2 day'))
AND (t2.date < t1.date)
)
ORDER BY date
OFFSET 1
you can use the INTERVAL length in a WHERE clause to filter gaps of at least that size.
Hope this helps.
source
share