I have two fields that are of type int lap_time_1
and lap_time_2
. Is there a mysql query to select the records whose difference (absolute value) between lap 1 and lap 2 is greater than 30?
Subtract the expected value from the actual value (or the other way round) and get the absolute value of the difference: ABS(A2-B2)
Absolute difference and relative difference Percentages are commonly used to compare two numbers. There are two different ways to compare two objects: • The absolute difference is the actual difference between the compared value and the reference value: absolute difference = compared value − reference value.
SQL Server DIFFERENCE() Function The DIFFERENCE() function compares two SOUNDEX values, and returns an integer. The integer value indicates the match for the two SOUNDEX values, from 0 to 4. 0 indicates weak or no similarity between the SOUNDEX values. 4 indicates strong similarity or identically SOUNDEX values.
The difference, taken without regard to sign, between the values of two variables; and in particular of two random variables.
This assumes lap_time_1 and lap_time_2 are two columns and the data is held on the same row.
SELECT *
FROM YourTable
WHERE ABS(lap_time_1 - lap_time_2) > 30
MySQL does have an absolute value (ABS) mathematical function. So you could do something like this:
SELECT *
FROM lap
WHERE ABS(lap_time_1 - lap_time_2) > 30;
SELECT *
FROM MyTABLE
WHERE ABS(lap_time1 - lap_time2) > 30
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With