SQLite Forum

Get column rank from values in selected row
Login
I made things difficult by keeping the months column as real and looking at lower and higher months rows.
just providing an integer month, ranging from 0 to 37 makes things a lot easier and this simple SQL:

select centile from
weight_centiles_m36
where male = ? and
age_months = ?
order by abs(? - weight)
limit 1

With the supplied parameters sex, months and weight gets the centile nearest to the provided data. This is for now good enough.
Will have a look at making the centile more accurate, based on the difference between the provided weight and picked weight from the normalized table (made as suggested by Ryan Smith).

I couldn't make the formula as in the quoted file work to get the outcome it should give:

To obtain the z-score (Z) and corresponding percentile for a given measurement (X), use the following equation:

    ((X/M)**L) – 1
Z = ————————-, L≠0
    LS

or

Z = ln(X/M)/S ,L=0

where X is the physical measurement (e.g. weight, length, head circumference, stature or calculated BMI value) and L, M and S are the values from the appropriate table corresponding to the age in months of the child (or length/stature). (X/M)**L means raising the quantity (X/M) to the Lth power.
For example, to obtain the weight-for-age z-score of a 9-month-old male who weighs 9.7 kg, we would look up the L, M and S values from the WTAGEINF table, which are L=-0.1600954, M=9.476500305, and S=0.11218624. Using the equation above, we calculate that the z-score for this child is 0.207. This z-score corresponds to the 58th percentile.

Not sure what exactly is meant with LS as in the first formula.

Nearly there though.


RBS