WHERE + COUNT to exclude a lifecycle bucket from a volume count
The CRO wants a count of every opportunity we're tracking that is NOT Closed-Lost — open pipeline plus Closed-Won, basically. The raw row count in `revops_opportunities` includes lost deals, which inflates the number in her board deck. Give me the count where `stage != 'Closed-Lost'`. Single number.
| Column | Type | Key |
|---|---|---|
| opportunity_id | INT | PK |
| account_id | INT | FK → revops_accounts |
| owner_user_id | INT | FK → revops_users |
| name | TEXT | |
| stage | TEXT | |
| amount | REAL | |
| close_date | TEXT | |
| created_date | TEXT | |
| is_closed | INT | |
| is_won | INT |
Each hint you reveal reduces the XP you can earn. Try the query first.
`stage != 'Closed-Lost'` is the filter. You could also write `stage <> 'Closed-Lost'` — same meaning.
`SELECT COUNT(*) FROM revops_opportunities WHERE stage != 'Closed-Lost'` gets you there. One row, one column.
If you're used to filtering lists of stages you might reach for `stage NOT IN ('Closed-Lost')` — same result for one-value lists, but spelled two ways for the same logic. Use whichever reads cleaner to your team.