Calculating Obesity Metrics in Patient Data from SQLite Database

Medium
2
61.1% Acceptance

The database contains a table called patients, and your task is to extract specific columns along with a computed column.

Task Description

Your task is to write a SQL query that shows the patient_id, weight, height, and an additional computed column isObese from the patients table. The isObese column should be computed using the formula for BMI. Here's a (dummy) Python implementation:

def is_obese(weight_kg, height_meter): bmi = weight_kg / (height_meter ** 2) if bmi >= 30: return 1 else: return 0

The isObese column should return a boolean value, 0 or 1.'

Concepts to Know

  • SELECT statement: To choose the columns you want to display.
  • Mathematical Functions: To perform the required calculations for isObese.

Final columns must be patient_id, weight, height, isObese

Sample Output

Here is a sample output limited to 2 rows from the query

patient_idweightheightisObese
1651560
4529911671

Good luck!