Seems that it should be simple enough to reverse engineer the bmi formula when you have the BMI and weight to get height -but perhaps not enough coffee today
(kg/power(m,2)) = BMI
but if I have
with T as (select 72.6 as kg, 28.35 as BMI_supplied from dual)
what is the reverse to get the height (should be 1.6m)
Thanks in advance for your time.
CodePudding user response:
Rearrange the equation:
| Step | Equation | Action |
|---|---|---|
| 1. | BMI = weight / height2 | |
| 2. | BMI × height2 = weight | Multiply both sides by height2 |
| 3. | height2 = weight / BMI | Divide both sides by BMI |
| 4. | height = SQRT(weight / BMI) | Take the square root of both sides |
So:
WITH T (weight_kg, BMI_supplied) AS (
SELECT 72.6, 28.35 FROM DUAL
)
SELECT weight_kg,
SQRT(weight_kg / BMI_supplied) AS height_m,
BMI_supplied
FROM T;
Which outputs:
WEIGHT_KG HEIGHT_M BMI_SUPPLIED 72.6 1.60026452839727746261804822638120931361 28.35
db<>fiddle here
