Building a query has endless directions you can head in! Let's take a look at the different parts of a query.
Parameters
On the query builder screen, you'll notice an empty row, as shown below.
Each line in a query is considered a "parameter". You can add multiple parameters to refine the criteria of your query.
Similar to Filters, this is where you can add a list of query parameters, or a query group.
- Field: The options you can find here depend on the Query type - they will typically align with the fields available in that object. You can also type ahead to search for a particular field, so if you want to look for anything address-related, you can start typing "address."
- For example: If you're running a Contact Query, you will be able to choose fields like Address, Tag, etc., because these are Contact-based fields. Sometimes, you will be able to use Contact Statistics, like Life-to-date Giving and so on.
- You will not be able to choose Gift Type, because this is associated with Gifts, not Contacts.
- For example: If you're running a Contact Query, you will be able to choose fields like Address, Tag, etc., because these are Contact-based fields. Sometimes, you will be able to use Contact Statistics, like Life-to-date Giving and so on.
- Operator: The options you can find here depend on the field selected. Operators will allow you to include or exclude resulting data depending on your needs. You can learn more about operators here.
- Value: This would be what you're looking for in that field. Depending on the data type and the operator, you may see "N/A" here.
- For example: If the field is Boolean (true/false), this value will show as N/A, because the value could only be true or false, and nothing else matters. *cue guitar riff*
And/Or Statements
If you are including more than one line in your query you will need to determine whether to use an "And" statement and/or an "Or" statement (or maybe even both!).
You can add several parameters as "And" statements by clicking the "And" button to the right of each row. Using "And" means that records must meet ALL of the listed criteria in order to be included in your results.
- For example, you want a list of Contacts who have given a total of $1000 Life-to-Date that are not tagged as a "Major Donor". We want our list to have both parameters: "LTD Giving is greater than or equal to $1000" AND "Tag is none of Major Donor".
Fun tip: Two or more query parameters from an object that does not match your query type will work together.
- For example, the address fields in a contact query will work together. "Primary address is true" and "State is Texas" will return ONLY contacts that have Texas as the state in their primary address.
You can also include "Or statements" by clicking the green OR button underneath the row. When you do this, a separate list of query parameters will begin. To be included in the results, records must only match one parameter or the other.
- For example, you want a list of donors who have given $1000 Life to Date OR a single gift of at least $500. You would only need a donor to have one of these two parameters to qualify. Therefore, we can use an OR statement in between these parameters.
Be careful with your OR statements; too many can give you an error message when running your query.
Now that you've taken time to understand the functions of building your query, you're ready to save and share for others to use!
Comments
0 comments
Article is closed for comments.