SQL (Structured Query Language) for BAs: filters, sorting and totals
Most analyst questions are a filter, an order and a total. Learn IN, BETWEEN and LIKE, then ORDER BY, LIMIT, DISTINCT and the five totals.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: a supermarket shelf. A shopper takes only the tins that match one brand and a price. A helper lines them up by date, keeps the first few, then counts them and adds the price.
Daily List is a made-up to-do app (SYNTHETIC / TRAINING ONLY). Sam, the , wants the open tasks due this week, in date order, plus a total.
What it is: (Structured Query Language) is a language for asking a database questions and for changing rows. A table is a grid. A row is one thing, such as one task, and a column is one fact, such as its title. such as IN, BETWEEN and LIKE keep some rows. Sort, limit and distinct then order those rows, stop after a few, or drop repeats. The five totals are COUNT, SUM, AVG, MIN and MAX. WHERE tests single rows. HAVING tests groups after a total, which is easy to mix up with WHERE.
Why it matters: Nina, the , asks which five open tasks are due first. A limit with no sort still returns five tasks, and they are the wrong five. A total that skips a blank also looks smaller than the real pile.
The shelf picture stops before groups. Grouping is the next lesson.
PLAIN WORDS · 1 in this section
- tins
- metal cans with lids
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the work.
THE REAL JOB Picking receipts, ordering them and adding them up.
- Filter
- Order
- Total
HOW THE PICTURE MAPS
| In the picture | In the work |
|---|---|
| Picking tins | WHERE |
| Date order | ORDER BY |
| Taking the top few | LIMIT |
| Adding up | SUM and COUNT |
WHERE THIS PICTURE STOPS
- A shelf is small, but tables are huge.
- A shelf has an order, but rows do not unless you ask.
- You see every tin, but empty values are hidden.
HOOK
Filter, order, total.
TELL A FRIEND
Shelf: pick, order, add.
OFTEN MIXED UP WITH SQL for BAs: SELECT and WHERE. That topic starts with and . This one adds the other filters, sorting and totals.
PRACTISE AND KEEP
Sources for this topic — 4 sources
- Market practice
SELECT command reference (PostgreSQL documentation) ↗ — PostgreSQL · PostgreSQL 18, SELECT: WHERE/HAVING/output aliases, functional dependence, NULL ordering and LIMIT; publisher page opened6November 2026. Dialect scope explicit.
PostgreSQL18 publisher documentation opened on6November2026: SELECT: WHERE/HAVING/output aliases, functional dependence, NULL ordering and LIMIT. No execution on PostgreSQL is claimed; engine-specific examples remain scoped to18.
- Market practice
Aggregate functions (PostgreSQL documentation) ↗ — PostgreSQL · PostgreSQL 18, §9.21 aggregates, NULL and empty input; publisher page opened6November 2026. Dialect scope explicit.
PostgreSQL18 publisher documentation opened on6November2026: §9.21 aggregates, NULL and empty input. No execution on PostgreSQL is claimed; engine-specific examples remain scoped to18.
- Market practice
SQLite: built-in aggregate functions ↗ — SQLite project · SQLite: built-in aggregate functions; NULL/empty aggregate results; SQLite numeric/text coercion. Publisher page opened6November 2026.
Publisher documentation opened on6November2026. Engine/version scope is explicit; other database implementations may differ. Teaching queries are synthetic, not a required publisher template.
- Simplified educational illustration
Payments Signal editorial teaching models — Payments Signal
What this simplifies: Daily List people, data and exercises are invented for teaching. Query results belong to the declared fixture and database version. Authorization, business identity, time bounds and unknown-value policy must be agreed in context; no universal mandatory query template is implied.
Used wherever diagrams, scenarios, figures, or example values are didactic constructions rather than sourced facts; every such use carries a simplifications disclosure. All people, companies, banks, and list entries in examples are fictional.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.