Average Deal Size by Market Segment
Problem
**[Asked at Salesforce]**
Salesforce categorises customers by size:
- **SMB** — 1–100 employees
- **Mid-Market** — 101–1 000 employees
- **Enterprise** — 1 001+ employees
For each segment, calculate the **average annual contract value** (ACV),
defined as `num_seats × yearly_seat_cost`.
Return `segment` and `avg_acv` (rounded to 2 dp), ordered by segment name.
Tables
Example rows — the live problem includes the full dataset.
customers
| customer_id | name | employee_count |
|---|
contracts
| contract_id | customer_id | num_seats | yearly_seat_cost |
|---|
Expected output
Your answer should return 3 rows with the columns segment, avg_acv.
Starter code (SQL)
SELECT *
FROM customers;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock