Joining Multiple Having Clauses

When you have several Having clauses, you can join them with the logical operators AND or OR. When you join more than one Having clause that is evaluated against a value prompted at runtime, you can also use the logical operator ELSE.

Assume you create two Having clauses.

When you run the report, SQR Production Reporting Studio behaves differently depending on the type of join you used to combine the Having clauses.

AND

The AND operator joins two or more conditions, and returns a row only if all of the conditions are true for that row.

In this example, if you use the AND operator as the logical operator and run the report:

  1. A prompt to enter a value for Customer Number appears.

    If you don't enter a value, SQR Production Reporting Studio stops running the report, defaults to the value specified for the Having clause or repeats the prompt until you enter a value.

  2. After you enter a value for Customer Number, a prompt to enter a value for Customer Name appears.

    When SQR Production Reporting Studio runs the report, it looks for a value in response to both prompts and displays those records that match both the Customer Number and the Customer Name.

OR

The OR operator joins two or more conditions, and returns a row if any of the conditions are true for that row.

In this example, if you use the OR operator as the logical operator and run the report:

  1. A prompt to enter a value for Customer Number appears.

    If you don't enter a value, SQR Production Reporting Studio stops running the report, defaults to the value specified in the Having clause, or repeats the prompt until you enter a value.

  2. After you enter a value for Customer Number, a prompt to enter a value for Customer Name appears.

    When SQR Production Reporting Studio runs the report, it looks for a value in response to both prompts and displays those records that match the either Customer Number or the Customer Name.

ELSE

The ELSE operator joins two or more conditions, but only evaluates one of them.

In this example, if you use the ELSE operator as the logical operator and run the report, a prompt to enter a value for Customer Number appears.

When SQR Production Reporting Studio runs the report, it looks for a value in response to the first prompt. If it finds a value, it skips the second prompt and displays the records that match the value in the first prompt (in this example Customer Number). If you do not enter a value in the first prompt, SQR Production Reporting Studio displays the second prompt and displays the matching records (in this example, Customer Name).