Skip to main content

Posts

Showing posts from March, 2019

SOQL Basics - WHERE, ORDER BY and LIMIT

WHERE, ORDER BY and LIMIT are three of the most commonly used techniques in SOQL. In this post we'll dive into them one at a time and look at some examples.
WHERE When you need to filter records, you can use a WHERE clause to define which records should be returned. You can use the AND, OR and NOT operators to define your filter. If you need to use multiple filters you can use parentheses to control how the filters are applied.

Let's look at some examples:

This query will return all Opportunities with an Amount greater than $50,000.

This query will return all Leads with a Lead Source of Web that were created This Week. The THIS_WEEK keyword is an example of a Date Literal and makes filtering on date and datetime fields much simpler.

This query will return all Accounts in CA, NY or FL based on Billing State. The IN keyword allows you to filter for records that have any of the values you define. Using NOT IN is a common technique and it has the opposite affect - returning recor…