MySQL Forums
Forum List  »  Newbie

Re: How to compare two records?
Posted by: Jassim Rahma
Date: October 12, 2021 03:06AM

This is what I am getting:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(ORDER BY bmi.bmi_id ASC) AS previous_bmi
FROM bmi
JOIN members ON members.mem' at line 3, Time: 0.245000s

The statement is working perfectly like this:

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;


but it throws the above error when I add:

LAG(bmi.bmi_value) OVER(ORDER BY bmi.bmi_id ASC) AS previous_bmi

Options: ReplyQuote


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


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.