COUNT with a date-range WHERE filter
Quick number for the LO call this afternoon. How many loans did we fund in Q1 2026 — that's `funded_date` between 2026-01-01 and 2026-03-31 inclusive? One number, alias it `q1_originations`.
| Column | Type | Key |
|---|---|---|
| origination_id | INT | PK |
| app_id | INT | FK → lending_applications |
| account_id | INT | FK → retail_accounts |
| funded_date | TEXT | |
| funded_amount | REAL | |
| term_months | INT | |
| interest_rate | REAL | |
| rate_type | TEXT | |
| arm_reset_date | TEXT | |
| fico_at_orig | INT | |
| dti_at_orig | REAL | |
| ltv_at_orig | REAL | |
| property_value | REAL | |
| lo_name | TEXT | |
| channel | TEXT | |
| current_status | TEXT | |
| closed_date | TEXT |
Each hint you reveal reduces the XP you can earn. Try the query first.
Aggregate over the originations rows whose funded_date falls inside the quarter — you want the count, not the list.
Two equivalent shapes for a date-window predicate: a BETWEEN, or paired boundary comparisons. Both inclusive on both ends. Production code sometimes prefers an exclusive upper boundary to avoid month-end timestamp drift, but for a date-only column either reads the same.
Single scalar output. Naming the count via an alias is what gives the report header a clean column to bind to.