I have a database table that holds order information and saves the current gold price (world price) automatically at the time of entry.
If I look back on the table, and the saved gold price has a difference with the current gold price of +100, O want to show that in a report.
How would I write the MySQL query to do this? I know how to do datediffs but not numeric values.
Example:
select * from table where saved_price < current_price - 100
Is there a better way to do this?
Use Abs if the sign of the difference doesn’t matter:
If the sign is interesting, your suggested approach is fine. I’d write it like this, but use the way you think is the most read- and understandable: