[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"glossary-window-function::en":3,"gloss-cluster-window-function::en":26,"gloss-next-window-function::en":9},{"slug":4,"category":5,"name":6,"definition":7,"meta_desc":8,"faq":9,"schema_markup":9,"related":10},"window-function","data-infra","Window Function","A window function computes a value for each row using a set of rows related to it, without collapsing those rows into one. An aggregate returns a single number per group; a window function returns a number per row while still seeing the group. That difference is what makes running totals, rankings, per-customer sequence numbers, moving averages and comparisons with the previous row expressible in a single SQL statement instead of a self-join or application code. The syntax has three parts worth understanding, because most confusion comes from mixing them up. PARTITION BY defines which rows belong together — the equivalent of GROUP BY but without collapsing. ORDER BY defines the order within a partition, and it is what makes running totals and lead\u002Flag meaningful. The frame clause defines how much of the ordered partition the function sees for the current row, which is how a moving average over a trailing window is expressed. Omitting the frame leaves a default that is not always what people expect, and is a common source of results that look almost right. In analytics work they are the standard tool for the questions that dominate product reporting: each user's first and most recent event, the gap between consecutive events, a rank of accounts by revenue within each region, a rolling seven-day active count. They are also expensive on large tables because they require ordering within each partition, so on a warehouse it is worth checking whether the partitioning column is one the storage layout already supports.","A window function returns a value per row while seeing related rows — PARTITION BY, ORDER BY and the frame clause, and why the default frame surprises people.",null,[11,14,17,20,23],{"slug":12,"name":13},"columnar-storage","Columnar Storage",{"slug":15,"name":16},"data-warehouse","Data Warehouse",{"slug":18,"name":19},"materialized-view","Materialized View",{"slug":21,"name":22},"olap","OLAP (Online Analytical Processing)",{"slug":24,"name":25},"retention-curve","Retention Curve",[27,31,34,37,40,44,47,50,53,56,60,61],{"slug":28,"category":5,"name":29,"updated_at":30},"acid","ACID","2026-08-24T02:46:37+00:00",{"slug":32,"category":5,"name":33,"updated_at":30},"ann-search","ANN Search",{"slug":35,"category":5,"name":36,"updated_at":30},"backpressure","Backpressure",{"slug":38,"category":5,"name":39,"updated_at":30},"batch-processing","Batch Processing",{"slug":41,"category":5,"name":42,"updated_at":43},"bm25","BM25","2026-08-24T02:46:38+00:00",{"slug":45,"category":5,"name":46,"updated_at":30},"cache","Cache",{"slug":48,"category":5,"name":49,"updated_at":30},"cap-theorem","CAP Theorem",{"slug":51,"category":5,"name":52,"updated_at":30},"change-data-capture","Change Data Capture (CDC)",{"slug":54,"category":5,"name":55,"updated_at":30},"chroma","Chroma",{"slug":57,"category":5,"name":58,"updated_at":59},"chunk-overlap","Chunk Overlap","2026-08-24T03:30:02+00:00",{"slug":12,"category":5,"name":13,"updated_at":30},{"slug":62,"category":5,"name":63,"updated_at":30},"connection-pooling","Connection Pooling"]