Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam Certified Platform Developer II All Questions

View all questions & answers for the Certified Platform Developer II exam

Exam Certified Platform Developer II topic 1 question 84 discussion

Actual exam question from Salesforce's Certified Platform Developer II
Question #: 84
Topic #: 1
[All Certified Platform Developer II Questions]

How can the DISTANCE and GEOLOCATION functions be used in SOQL queries? (Choose two.)

  • A. To filter results based on distance from a latitude and longitude
  • B. To get the distance results from a latitude and longitude
  • C. To order results by distance from a latitude or longitude
  • D. To group results in distance ranges from a latitude and longitude
Show Suggested Answer Hide Answer
Suggested Answer: AC 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
rodmfpwc
Highly Voted 3 years, 9 months ago
Explanation: DISTANCE and GEOLOCATION can be used to filter and order. Ex: String queryString = 'SELECT Name, Email__c ' + 'FROM Account ' + 'WHERE DISTANCE(BillingAddress, GEOLOCATION('+lat+','+lon+'), \'mi\') < 20 ' + 'ORDER BY DISTANCE(BillingAddress, GEOLOCATION('+lat+','+lon+'), \'mi\') ' + 'LIMIT 10'; List<Account> accList =Database.query(queryString);
upvoted 7 times
...
beardAnt
Most Recent 1 month, 1 week ago
Selected Answer: AC
Filter and order
upvoted 1 times
...
moitam
1 year, 2 months ago
Selected Answer: AB
Option C is not correct because it says “To order results by distance from a latitude or longitude”. This implies that you can order results by distance from either a latitude or a longitude, but not both. However, the DISTANCE function requires both a latitude and a longitude to calculate the distance from a location. Therefore, you cannot order results by distance from a latitude or longitude, but only from a latitude and longitude pair.
upvoted 2 times
code_breaker_27
1 year, 1 month ago
Just to add, I think you can only get the location but not the distance this way. SELECT Name, Location__latitude__s, Location__longitude__s FROM Warehouse__c
upvoted 1 times
...
...
lorenac2
1 year, 10 months ago
Selected Answer: AC
Reference: https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_geolocate.htm
upvoted 3 times
...
Liquad
3 years, 1 month ago
SELECT Name, StreetAddress__c FROM Warehouse__c WHERE DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), 'mi') < 20 ORDER BY DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), 'mi') LIMIT 10
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...