Self-inclusive baselines flatter — a reading compared to an average containing itself is pulled toward normal, most strongly in small windows where anomalies matter most. EXCLUDE CURRENT ROW states the intent in the frame; EXCLUDE TIES/GROUP extend it to peer rows sharing the sort value. Support is sparse (DuckDB yes); the expansion is arithmetic: (SUM(x) OVER w - x) / NULLIF(COUNT(*) OVER w - 1, 0).
SELECT d, AVG(x) OVER ( ORDER BY d ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING ) AS peer_avg FROM v ORDER BY d;
SELECT d, AVG(x) OVER ( ORDER BY d ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW ) AS peer_avg FROM v ORDER BY d;
Each row's peer average included itself, pulling it toward normal — EXCLUDE CURRENT ROW trims the row out of its own frame, so the middle row's peers average a true 20, not a self-inflected 20.
EXCLUDE where supported; the subtract-self expansion elsewhere.
EXCLUDE support is sparse (DuckDB yes, many engines no) — the subtract-self expansion is the portable form.