I am working on a latitude/longitude distance search and am having trouble finding the closest results.
The issue is that I do 4 calculations and if I "ORDER BY", I get them sorted by first, then second, then third, then fourth value, as to be expected. What I need to do is find the smallest value of the 4 calculations first and then I can order by that one value.
Problem is, I am at beginner level SQL statements.
Here is the problem in more simplified terms:
a = 40
b = 10
c = 50
d = 20
I need to find the smallest value of the following to use as the value to sort my results:
a - column_1
,column_1 - b
,c - column_2
,column_2 - d
The issue is that I do 4 calculations and if I "ORDER BY", I get them sorted by first, then second, then third, then fourth value, as to be expected. What I need to do is find the smallest value of the 4 calculations first and then I can order by that one value.
Problem is, I am at beginner level SQL statements.
Here is the problem in more simplified terms:
a = 40
b = 10
c = 50
d = 20
I need to find the smallest value of the following to use as the value to sort my results:
a - column_1
,column_1 - b
,c - column_2
,column_2 - d