Count All Three Salary Categories Including Empty Ones
Company: Google
Role: Software Engineer
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Other
### Problem
Return category and accounts_count for all three source categories: Low Salary for income < 20000, Average Salary for 20000 through 50000 inclusive, and High Salary for income > 50000. Always emit the three categories, with 0 for an empty category. Row ordering is unrestricted.
### Tables
Table: `Accounts`
```text
+-------------+------+
| Column Name | Type |
+-------------+------+
| account_id | int |
| income | int |
+-------------+------+
account_id is the primary key (column with unique values) for this table.
Each row contains information about the monthly income for one bank account.
```
### Example
```text
Accounts (account_id,income): (1,19999), (2,20000), (3,50000), (4,50001)
Output (category,accounts_count): (Low Salary,1), (Average Salary,2), (High Salary,1)
If Accounts is empty, every one of the same three categories has count 0.
```
### What a Strong Answer Covers
- Return exactly the three named categories and apply their specified boundaries.
- Return zero for a category with no accounts.
### Follow-up Questions
- How would the query change if salary categories were stored in a separate table?
- How would you return the share of all accounts in each category?
Overview: Count accounts in each of the three salary categories, including categories that have no accounts.