I need to include one email address or one phone number in query output (includes video demo)

My query is showing multiple rows for phone numbers and email addresses and I only want to see one phone number and email. You may notice that when you output Email address or Phone number in query, query will return all email addresses and phone numbers on file for that constituent. This solution will walk you through how to get the primary email or the primary phone while not excluding constituents without a phone number or email address. This can also be used to query with only one email address or query with only one one phone number.

Article
Number:67354

Products:

Altru_Arts_Cultural

Option 1: Include only a primary email address and constituents without an email address

Start your query:

Navigate to Analysis, then click on Information Library

Click Add an ad-hoc query

Select the source view you need and click OK

Add fields to Include records where:

From the left column, expand Constituents and select Email Addresses. From the middle column, drag Primary email address to Include records where. Set the criteria to be Equal to Yes

Note: For a membership query, from the left column expand Members > then expand Constituents

To also include constituents without email addresses, from the middle column, drag Email addresses to Include records where. Set the criteria to be Blank.

In Include records where, click the second line item and select the OR feature

Group the two fields together using the parenthesis feature:

In Include Records Where, select the first line item: Email Addresses\Primary Email address, and click Add Left Parenthesis button.

In Include Records Where, select the second line item: Email Addresses\Email Address, and click Add Right Parenthesis button.

Add fields to Results fields to display:

From the left column, select Constituents. From the middle column, drag Email address to Results fields to display (as well as any other fields you would like to output)

Option 2: Include only a primary phone number and constituents without a phone number

Start your query:

Navigate to Analysis, then select Information library

Click Add an ad-hoc query.

Select the source view you need and click OK

Add fields to Include records where:

From the left column, expand Constituents and select Phones. From the middle column, drag Primary phone number to Include records where. Set the criteria to be Equal to Yes

Note: For a membership query, from the left column expand Members > then expand Constituents

To also include constituents without phone numbers, from the middle column drag Number to Include records where. Set the criteria to be: Phone number\Number is blank.

In Include records where, click the second line item and select the OR feature

Group the two fields together using the parenthesis feature:

In Include Records Where, select Phones\Primary phone number and click Add Left Parenthesis button.

In Include Records Where, select Phones\Number and click Add Right Parenthesis button

Add fields to Result fields to display:

From the left column, select Constituents. From the middle, drag Number to Results fields to display (as well as any other fields you would like to output)