Practice Interview Questions
| Question | Status |
|---|---|
Write a query to find the top 3 states with the most 5-star reviews. Your output should include the state name and the number of 5-star reviews they received. In case of a tie between states, you should rank them by their alphabetical order.
Hint: Your final result should only include 3 states.
businesses table:
| Column Name | Description |
|---|---|
| business_id | Unique identifier for each business |
| name | Name of the business |
| state | State where the business is located |
reviews table:
| Column Name |
|---|
| review_id | Identifier for each review |
| business_id | Identifier for the business |
| rating | Star rating given |
| state | num_five_star |
|---|---|
| CA | 50 |
| NY | 32 |
| MA | 20 |
Write a query to find the top 3 states with the most 5-star reviews. Your output should include the state name and the number of 5-star reviews they received. In case of a tie between states, you should rank them by their alphabetical order.
Hint: Your final result should only include 3 states.
businesses table:
| Column Name | Description |
|---|---|
| business_id | Unique identifier for each business |
| name | Name of the business |
| state | State where the business is located |
reviews table:
| Column Name | Description |
|---|---|
| review_id | Identifier for each review |
| business_id | Identifier for the business |
| rating | Star rating given |
| state | num_five_star |
|---|---|
| CA | 50 |
| NY | 32 |
| MA | 20 |