SQLite Forum

Get column rank from values in selected row
Login
This seems a bit better:

select coalesce(round(max(min(c * (m / ?) * (? / w), 97), 3), 0), "") as cent from
(select
age_months as m,
weight as w,
abs(1 - age_months / ?) as p1,
abs(1 - weight / ?) as p2,
centile as c
from weight_centiles_m36
where male = ?
order by p1 asc, p2 asc limit 1)

where parameters are:
months, weight, months, weight

Still this doesn't give smooth chart-like values and I think I may need to interpolate month and weight values in the source table.

RBS