# CUBE keyword

> **For AI agents:** the complete documentation index is at [llms.txt](https://questdb.com/docs/llms.txt). Every page is available as markdown by appending `.md` to its URL, or by sending an `Accept: text/markdown` request header.

CUBE SQL keyword reference for computing aggregates over every combination of columns in a single query.

`CUBE` computes aggregates for every combination of the listed columns in a
single query. For example, `GROUP BY CUBE(symbol, side)` returns a row per
symbol and side, a total per symbol, a total per side, and a grand total,
which suits cross-tabulation. With N columns, `CUBE` produces 2^N grouping
sets. It works with both `GROUP BY` and `SAMPLE BY`.

For syntax, examples, and limitations, see
[CUBE](/docs/query/sql/grouping-sets/#cube) on the GROUPING SETS page.
