# ROLLUP 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.

ROLLUP SQL keyword reference for computing hierarchical subtotals and a grand total in a single query.

`ROLLUP` computes hierarchical subtotals in a single query. For example,
`GROUP BY ROLLUP(symbol, side)` returns a row per symbol and side, a subtotal
per symbol, and a grand total, which suits reports that drill down from a
total to its parts. With N columns, `ROLLUP` produces N+1 grouping sets. It
works with both `GROUP BY` and `SAMPLE BY`.

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