Aliases in query

Hello, it is possible to make somehow this query in Backendless?

SELECT *, ( (22.906847 - (IF (ads.lat < 0, ads.lat * -1, ads.lat))) + (43.172896 - (IF (ads.long < 0, ads.long * -1, ads.long))) ) as diff_distance FROM ads ORDER BY diff_distance DESC

Thank you.

We do not support the “IF” operator in the SQL statements. However, you can run geo searches in a radius or a rectangular area using the Geolocation service API.

Hello Mark,

Is possible order by distance?

var query = new Backendless.DataQuery(); 
query.options = {}; 
query.options.sortBy = '??????????'; 
query.condition = "distance( -22.982812, -43.218305, position.latitude, position.longitude ) < km(30)"; 
 
console.log(Backendless.Persistence.of(new $rootScope.Classes.Ads()).find(query));


Raul,

Query results are automatically ordered by distance, you do not need to specify the sorting options.

Mark