This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- COUNT ALL location gaps over a period | |
WITH AisLocationGaps AS ( | |
SELECT | |
v.name, | |
v."imoIdentifier", | |
l.dtg, | |
COALESCE( | |
LAG(l.dtg) OVER (PARTITION BY v."activeMmsiIdentifier" ORDER BY l.dtg), | |
NOW() - INTERVAL '4 months' | |
) AS previous_dtg, |