You are here: API Reference > Calls > query > Query Statement Examples

Query Statement Examples

This page provides some examples of how queries can be constructed.

Simple Queries

The following query will return the account numbers and names for all accounts.

SELECT AccountNumber, Name FROM Account

The following query will return 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 will return 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 will return 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 will find all accounts with a purchase order number.

SELECT AccountNumber FROM account WHERE PurchaseOrderNumber != null

The following query will find 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 will find all accounts where AutoPay has been set to no (false).

SELECT AccountNumber FROM account WHERE AutoPay != true

See Also

Constructing Filter Statements

Copyright © 2008-2009 Zuora, Inc.