vehicle_id,
r - LAG(r) OVER tdiff AS dt,
calculate_distance(la, lo, LAG(la) OVER tdiff, LAG(lo) OVER tdiff, 'K') AS ds,
ds/time_to_sec(dt) AS speed
FROM trips, array_length(latitude, 1) l,
UNNEST(recorded_at, latitude, longitude) WITH ORDINALITY rr(r, la, lo, ro)
WHERE l > 1
WINDOW tdiff AS (PARTITION BY trip_id, vehicle_id ORDER BY ro DESC) LIMIT 1000;
повтор выражений или подзапросы
А что мешает calculate_distance(la, lo, LAG(la) OVER tdiff, LAG(lo) OVER tdiff, 'K')/(r - LAG(r) OVER tdiff) вписать?
Обсуждают сегодня