logo


58.1.4 Query Tutorial: The Funnel Concept


Now let's get a mental picture of what happens when you add lines to a query in the Query Editor. Take a look at the diagram below:

 

Query Tutorial: The Funnel Concept

This is what we call the Funnel Concept. This concept is a visual way for you to understand that, for each line you add to a Query, the following rules hold true:

If the conjunction is Or, the selection may get larger, but it will never get smaller;

If the conjunction is And, the selection may get smaller, but it will never get larger;

If the conjunction is Except, the selection may get smaller, but it will never get larger.

Testing the Funnel Concept

Just to see how this works, let's take the two-line query that we have already saved, and let's see what happens as the we change the conjunctions.

QUERY [Location] AND [Location]Demog_Last_Name #’Jones’

QUERY [Location] AND [Location]Stay_Days > ‘10’

As we go through the queries, we will perform each query as a one-line query so we can see the results. To save time and space, we will only show the number of records that the query returned.

Note: Because your data file may not be exactly the same as the data file that we used in these examples, the number of records that your queries return might be different from those shown below. The important factor is the relative number of records returned, not the exact numbers.

SINGLE LINE QUERY

QUERY [Location] AND [Location]Demog_Last_Name #’Jones’

Returns 8934 of 8964 Records

SINGLE LINE QUERY

QUERY [Location] AND [Location]Stay_Days > ‘10’

Returns 460 of 8964 Records

OK, let's see what happens as we add the second line to the first line in three separate queries, each time changing the conjunction. We start with And:

AND QUERY

QUERY [Location] AND [Location]Demog_Last_Name #’Jones’

QUERY [Location] AND [Location]Stay_Days > ‘10’

Returns 456 of 8964 Records

Compared to the one-line result, the funnel became smaller.

But if we use the same query again, and just change the conjunction to Or:

OR QUERY

QUERY [Location] AND [Location]Demog_Last_Name #’Jones’

QUERY [Location] OR [Location]Stay_Days > ‘10’

Returns 8938 of 8964 Records

Compared to the one-line result, the funnel became larger.

Now: what do you think will happen if we change the conjunction to Except?

EXCEPT QUERY

QUERY [Location] AND [Location]Demog_Last_Name #’Jones’

QUERY [Location] EXCEPT [Location]Stay_Days > ‘10’

Returns 8478 of 8964 Records

Compared to the one-line result, the funnel became smaller.

By the way: you may wonder why we have explained the Funnel Concept so thoroughly by repeating ourselves in a slightly different way. The reason is this:

Having a thorough understanding of the Funnel concept is essential if you want to become a power user of the STATIC Query Editor!

Query Tutorial: Query Line Order and the Funnel Concept

You need to know how the Query Line Order can affect the results. Let's use three query lines to build some tests. Our three query lines are:

SIMPLE QUERY

No Found

QUERY [Location] AND [Location]Demog_Last_Name #’Jones’

8932

SIMPLE QUERY

No Found

QUERY [Location] AND [Location]Stay_Days > ‘10’

460

SIMPLE QUERY

No Found

QUERY [Location] AND [Location]Out_Date > ‘01/01/1999’

3639

So let's experiment. The And-And order will be our starting point. Our test will be to see what happens if we change the order to Or-And, to And-Or, and to Or-Or.

In each case, we will show you the Query Editor, and then the number of records that result from that query.

AND AND Query

No Found

QUERY [Location] AND [Location]Demog_Last_Name #’Jones’

8932

QUERY [Location] AND [Location]Stay_Days > ‘10’

456

QUERY [Location] AND [Location]Out_Date > ‘01/01/1999’

214

Result: 214 of 8964 Records

AND OR Query

No Found

QUERY [Location] AND [Location]Demog_Last_Name #’Jones’

8932

QUERY [Location] AND [Location]Stay_Days > ‘10’

456

QUERY [Location] OR [Location]Out_Date > ‘01/01/1999’

3881

Result: 3881 of 8964 Records

OR AND Query

No Found

QUERY [Location] AND [Location]Demog_Last_Name #’Jones’

8932

QUERY [Location] OR [Location]Stay_Days > ‘10’

8936

QUERY [Location] AND [Location]Out_Date > ‘01/01/1999’

3624

Result: 3624 of 8964 Records

OR OR Query

No Found

QUERY [Location] AND [Location]Demog_Last_Name #’Jones’

8934

QUERY [Location] OR [Location]Stay_Days > ‘10’

8936

QUERY [Location] OR [Location]Out_Date > ‘01/01/1999’

8951

Result: 8951 of 8964 Records

Can you guess a General Rule that is implied by these results?

Here is the rule: The later the Or in the query order, the more records the query will return.

Can you guess why?



Harrowex Pty Ltd
http://www.hxmedical.com
Voice:+ 61 4 27 344 279
Fax: +61 3 52 439 019
static@hxmedical.com