QUERY can summarize as well as filter. Wrap a column in an aggregate, sum, count, avg, min or max, and add group by for the column that defines the groups:
select C, sum(F) group by C gives one row per category with its total revenue, sorted by category. Every column in select must either be grouped or wrapped in an aggregate; otherwise QUERY stops with an error that names the column to add.
The result's headings are built from the function and the original heading, such as "sum Revenue". Rename them with label, at the end of the query: label sum(F) 'Revenue'. You can also sort by an aggregate: order by sum(F) desc.
pivot turns the values of a column into columns: select C, sum(F) group by C pivot B gives one row per category and one column per month. Pivot columns are sorted A to Z as text, which is why months stored as "2026-01" line up and "Jan", "Feb", "Mar" would not.
A where clause filters rows before they're grouped.