Skip to content

Instantly share code, notes, and snippets.

@kgorman
Created October 25, 2019 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgorman/cc6d39b7941e58ed199f0cfe376c9665 to your computer and use it in GitHub Desktop.
Save kgorman/cc6d39b7941e58ed199f0cfe376c9665 to your computer and use it in GitHub Desktop.
sample sql
-- new to my airspace
SELECT icao, pings FROM (
SELECT icao, speed,
COUNT(*) OVER (PARTITION BY icao ORDER BY eventTimestamp RANGE BETWEEN INTERVAL '60' SECOND PRECEDING AND CURRENT ROW) AS pings
FROM airplanes
) WHERE pings < 5
AND icao like 'A%'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment