The approach I would use would be to create a scoring function (your stored process) that would evaluate a given standard input distance from the average.
In proc, you will evaluate each criterion in the same way as:
INPUT AGE: 32 calculate MEAN of AGE WHERE (sex = m): 34.5 calculate STANDARD DEVIATION of AGE WHERE (sex = m): 2.5 calculate how many STDEVs 32 is from the 34.5 (also known as z-score): 1
Repeat this process for all numeric data types, adding them up and ORDER BY the sum.
In this case, the following scheme change will be required: the height has changed from the height of the foot / inch to strictly in inches.
Depending on your needs, you can also think of coming up with a custom scale for gender and skin color / hair color. Of course, you might think that such measures should not be taken into account because of how radically this would change the scoring function. If you decide, you will need to find some number that will be added to the above SUM ... but this is difficult, because nominative variables are not easily translated into such things.
If you find that hair color / skin color can be conveniently conveyed, say, by a continuous color spectrum, your highlight tidbit will be the same ... the color value of the input and the color value of the average values ββand standard deviations.
A query that finds your matches will be something like:
SELECT ABS(INPUT_AGE - AVG(AGE)) / STD(AGE) AS age_z, ABS(INPUT_WT - AVG(WT)) / STD(WT) AS wt_z, ... (age_z + wt_z + ...) AS score FROM `table` ORDER BY score ASC
source share