-- Distance outliers: trips with impossible or suspicious distance in last 7 days
SELECT
    imei,
    start_time,
    end_time,
    distance_km,
    source
FROM tracksolid.trips
WHERE start_time > NOW() - INTERVAL '7 days'
  AND (
      distance_km < 0
      OR distance_km > 500
  )
ORDER BY distance_km DESC;
