GROUP BY
GROUP BY changes your result’s grain. One row per order becomes one row per customer, country, or reporting period.
Choose the grouping key
GROUP BY customer_id places orders for each customer into one group. The output contains one row for each distinct customer_id present in the input.
Aggregate within each group
SUM(sales) now operates separately inside every group. The ungrouped result returns one overall total; grouping produces several totals.
Selected columns
Use grouping keys or aggregates in the SELECT list. SQLite permits some bare columns that other databases reject; their values can be arbitrary. Do not rely on that permissive behavior.
Several keys and NULL
GROUP BY country, city produces one row per country-city pair. NULL grouping values are collected together. Filter rows before grouping if your question concerns only a subset.