The Sub-Query Builder allows a user to search for records that are either in or not in a subset of records generated with an SQL statement.
Here is an advanced query that uses a Sub-Query. Although this query is for a very specific scenario, you could apply this logic to any other area in netFORUM We want to run a query that will return a list of all individuals and all their active relationships, as long as that individual has at least one active relationship with the relationship code of Project Manager. So if Jane Doe has at least one Project Manager role (and it's active), then we want to return ALL her relationships, even those that are NOT of the code Project Manager.
Let's take a look at this query one step at a time.
You cannot simply do this:
If you add this filter, it will return ONLY relationships that have the Project Manager code and you will leave out any of the individual's other relationships.
Instead, you want to run a Sub-Query that asks "return any individuals who have any relationships that have the Project Manager role." You need a Sub-Query for this.
In this Sub-Query, we want to define a set of individual relationships, and we want to choose only those individuals who exist in that set. Therefore our Column to Query must be the Individual -> Primary Key, and we need to say that it is in the set of relationships defined by the Individual Key of those relationships.
First, select the Individual -> Primary Key as the Column to Query and for the Operator choose Is In.
Next, click the Sub-Query button to open a Sub-Query.
In your Sub-Query, you want to define the set of Project Manager relationships, and you want to define them by the Individual Key so that you can match the Individual -> Primary Key chosen in your main query with the Affiliation -> Individual Key column in your Sub-Query subselect. [Advanced Option: if you want to choose different relationship type each time you run this query, then you might want to check the Ask At Run-Time checkbox to give this query more flexibility.]
Therefore, for the Pick Table for Sub-Query, you choose Affiliation. For the Pick Column to Select for Sub-Query, you choose the ixo_ind_cst_key (Individual Key) as this is the column that corresponds to the Individual -> Primary Key.
After you have chosen your Column to Select for Sub-Query, next you must define the filter conditions in your Sub-Query. You will choose filtering conditions for the Relationship Type, and choose End Date is NULL or End Date is greater than the Current System Date, which you enter as {CurrentDate}.
Once you have entered these conditions, press Return to lock in your Sub-Query and return to the main query. Then press the OK button to add this condition to your query.
You will add a few more filter columns to select to output only active relationships, just as you did for the Sub-Query.
In this query, we sort on Customer --> Sort Name and then Organization --> Organization Name.
Finally, in the Output area, select the Affiliation --> columns to pull in all the affiliations for the Individual. You will also want to select the Organization --> Organization Name to pull in the name of the Organization.
Note that the Title and Organization Name in the list results are not the individual's primary title and organization, but the title and organization for each relationship.
Here is a query with a variation on the Sub-Query in the previous scenario. In this scenario, we want to output a list of individuals, as long as the individual does not belong to a certain mailing list.
You cannot simply choose this condition:
If you choose this, then you will exclude any individuals who have no mailing lists at all, and you will include individuals who have any mailing list that is NOT the Training Webinar Invite List.
Instead you need a Sub-Query that will exclude any individuals who belong in the set of mailing list recipients of a specific mailing list:
Sub-Query Builder
Defined Query
[Mailing List Detail->Mailing List Key] Is Equal To [Unsubscribe]
You can only do this with a Sub-Query. Here are the steps to add this Sub-Query:
In effect, what this query condition is doing is this: It is saying include only Individuals in which the Individual DOES NOT belong to the "unsubscribe" mailing list. If you belong to NO mailing lists, you will get the person in the query. If they belong to one or more mailing lists, none of which are NOT the "unsubscribe" one, then they will appear in the query.
Suppose you're writing a query and you'd like to pull in any individuals who are members of certain committees.
If you're running this from the Individual group item, then follow the steps below to create a query with a Sub-Query to do this.
An alternate way to write this query is to type a list of committee codes, enclosed with single quotes and separated by commas, in one condition, rather than adding each committee code as its own condition and adding additional "OR". This way is quicker but is more prone to error in case you mistype a code. In the example below, instead of one line for each committee, we list all the committees ('A','B','C','D','E') in one line. Either way you write the query, the results will be the same.
Be sure to enclose each code in single quotes, and separate with commas. Do not enclose this list with parentheses or brackets; the Sub-Query builder will take care of that for you.
If you are trying to find the table in the Pick Table for Sub-Query drop-down list, but you are not finding the table, it could be because of an underlying setup issue. Please report this issue to your Abila representative. From a technical perspective, there needs to be a List Table and From Table configured for the table that you are not seeing; your Abila representative can do this for you.