Query Statement Examples
From API Documentation
This page provides some examples of how queries can be constructed.
Simple Queries
The following query returns the account numbers and names for all accounts.
select AccountNumber, Name from Account
The following query returns the account IDs and first (personal) and last (family) names for all contacts.
select AccountId, FirstName, LastName from Contact
Queries with Filter Statements using WHERE
The following query returns the IDs and names for all accounts where the names start with the letter A and are followed by zero or more characters.
select id, Name from Account where Name like 'A%'
The following query returns the last (family) names for all contacts where the postal code starts with the numbers 940.
select id, LastName from Contact where PostalCode like '940%'
The following query finds all accounts with a purchase order number.
select AccountNumber from account where PurchaseOrderNumber != null
The following query finds all accounts where AutoPay has been set to yes (true) and the status of those accounts is active.
select AccountNumber from account where AutoPay = true and Status='Active'
The following query finds all accounts where AutoPay has been set to no (false).
select AccountNumber from account where AutoPay != true
