// window reference

SQL GROUPS frame support by engine

The support matrix for the GROUPS frame type, with the emulation path for the two engines that lack it.

카테고리
창
Returns
frame type
In this category
60 of 79

구문

ORDER BY d GROUPS BETWEEN 1 PRECEDING AND CURRENT ROW

엔진 지원

엔진Support메모
SQL Server Not built in not supported, including SQL Server 2025
PostgreSQL 예 since PostgreSQL 11
MySQL Not built in not supported in MySQL 8.x (ROWS and RANGE only)
SQLite 예 since SQLite 3.28.0 (2019-04-16), alongside EXCLUDE
Oracle 예 since Oracle 21c, alongside EXCLUDE and the WINDOW clause

예시

SQL Server

-- GROUPS BETWEEN 2 PRECEDING AND CURRENT ROW, emulated
WITH per_day AS (
  SELECT day, SUM(price) AS s, COUNT(price) AS n
  FROM prices
  GROUP BY day
), framed AS (
  SELECT day,
         SUM(s) OVER (ORDER BY day ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) AS fs,
         SUM(n) OVER (ORDER BY day ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) AS fn
  FROM per_day
)
SELECT p.day, p.price, f.fs * 1.0 / NULLIF(f.fn, 0) AS ma3_groups
FROM prices p
JOIN framed f ON f.day = p.day;

알아 두면 좋은 정보

  • SQL Server and MySQL emulation: GROUP BY the ORDER BY value so each tie group becomes one row carrying SUM(x) and COUNT(*), run a ROWS frame over those rows, then join back to the detail rows.
  • A ROWS frame over DENSE_RANK() as the ORDER BY does not emulate GROUPS: ROWS still counts individual rows, so tied rows get different frames.
  • GROUPS and EXCLUDE arrived together everywhere: PostgreSQL 11, SQLite 3.28 and Oracle 21c added both, and SQL Server and MySQL have neither.

Questions about GROUPS Frame Support

Which engines support GROUPS frames today?

PostgreSQL (11+), SQLite (3.28+) and Oracle (21c+). SQL Server and MySQL do not; cross-engine code needs the aggregate-then-ROWS rewrite.

Is GROUPS frame the same as GROUP BY?

No connection: GROUPS is a frame type describing which rows a window function sees, based on how many peer-groups away the boundary sits. GROUP BY collapses rows.

Browse every function in the SQL function reference, or see what the SQLly desktop app does for your database.

Cheat sheets for the engines that have it: PostgreSQL, SQLite, Oracle.

// fewer lookups

Functions your engine actually has

SQLly's completion lists the built-in functions of the engine you're connected to, whether that's SQL Server, PostgreSQL, MySQL, SQLite or Oracle. Hover a function for help, and signature hints show each argument as you type.