How to compare two records?
Hi,
I am using the below statement to get the latest bmi_value
SELECT MAX(bmi.bmi_id), bmi.member_id, members.first_name, members.last_name, bmi.bmi_age,
bmi.bmi_gender, bmi.bmi_height, bmi.bmi_weight, bmi.created_date, bmi.bmi_value
FROM bmi
JOIN members ON members.member_id = bmi.member_id
GROUP BY bmi.member_id
ORDER BY bmi_id DESC;
I want to get the value just before that and add a field compare so if the new value is higher then compare will be "+" and if it's lower then it will be "-"
For example:
bmi_id. bmi_value
99. 50
bmi_id. bmi_value
100. 50.5
bmi_id. bmi_value
101. 50.2
so the result of this using the above statement should give:
bmi_id. bmi_value. compare
101. 50.2 -
Kindly help..
Thanks,
Jassim