From rows to summaries
DISTINCT deduplicates row values; aggregates collapse many rows into one number.
COUNT(*)— count rows.COUNT(col)counts non-NULL values of col.SUM(col),AVG(col),MIN(col),MAX(col)— the obvious ones.GROUP_CONCAT(col, sep)— concatenate values into a string.TOTAL(col)— like SUM but returns 0 for empty input (SUM returns NULL).
Tip:
SELECT count(*) on a table without a WHERE is O(n) in SQLite — it actually walks the rows. If you call it constantly, cache the count or maintain a counter row. (Postgres has the same property without REINDEX work.)