MySQL Forums
Forum List  »  Newbie

How to compare two records?
Posted by: Jassim Rahma
Date: October 11, 2021 05:51AM

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

Options: ReplyQuote


Subject
Written By
Posted
How to compare two records?
October 11, 2021 05:51AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.