Median Household Income
Start Timer
0:00:00
A marketing company is conducting a survey on household incomes in various cities. Now they’re asking for your help with analytics. Write a SQL query to compute the median household income for each city.
Note: Assume that the median is the middle value in an odd set of numbers, and the average of the two middle numbers in an even set.
Example:
Input:
survey_responses table
| Column | Type |
|---|---|
| id | INTEGER |
| city | VARCHAR |
| household_income | INTEGER |
Output:
| Column | Type |
|---|---|
| city | VARCHAR |
| median_income | INTEGER |
.
.
.
.
.
.
.
.
.
Comments