MySQL Forums
Forum List  »  Newbie

Re: How to compare two records?
Posted by: Jassim Rahma
Date: October 13, 2021 02:56PM

Hi Peter,

Appreciate your help.. But I corrected the typo and still getting error.


SELECT b.bmi_id, b.bmi_weight, b.prev, b.diff
FROM
(
SELECT max(bmi_id) AS last_bmi FROM bmi WHERE member_id = 100
) AS a
JOIN
(
SELECT bmi_id, bmi_weight, LAG(bmi_weight) over w AS prev, bmi_weight-LAG(bmi_weight) over w AS diff
FROM bmi WHERE member_id = 100 window w AS (ORDER BY bmi_id)
) AS b ON a.last_bmi = b.bmi_id;



Regards, the double datatype, you are 100% right, I changed it to decimal(5,2)

Options: ReplyQuote


Subject
Written By
Posted
October 11, 2021 05:51AM
Re: How to compare two records?
October 13, 2021 02:56PM


Sorry, you can't reply to this topic. It has been closed.

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.