Filtering Provinces by Sum of Patient Heights in SQLite
Medium
2
81.3% Acceptance
You need to write a SQL query to show the province_id
along with the sum of heights for all patients belonging to each province_id
. Filter the output to only include those provinces where the total sum of heights of its patients is greater than or equal to 7,000.
Important Concepts
- Aggregation: You'll need to aggregate data, specifically using the
SUM
function to sum up the heights of patients. - Grouping: The
GROUP BY
clause will be essential to group patients based on theirprovince_id
. - Filtering Groups: You'll have to use the
HAVING
clause to filter groups after aggregation.
Column names must be province_id
and sum_height
Start writing your SQL query to solve this problem!