Click the Show Advanced Settings icon next to the rule or Decision Table name Select Advanced Mode. Select insert pattern to add a pattern. In the Surround With dialog select Pattern Block. For more information, see Click OK. In the pattern select the fir

4-38 Oracle Fusion Middleware Users Guide for Oracle Business Rules Figure 4–49 Using Aggregate Functions with Rules Red Color Total Cost Rule To use advanced mode aggregates: 1. Select or create the rule or Decision Table where you want to use an aggregate function.

2. Click the Show Advanced Settings icon next to the rule or Decision Table name

see Section 4.5.1, How to Show and Hide Advanced Settings in a Rule or Decision Table .

3. Select Advanced Mode.

4. Enter the fact type you want to work with.

5. Select insert pattern to add a pattern.

6. Select the new pattern. 7. Right-click the pattern and select Surround With.... This displays the Surround With dialog.

8. In the Surround With dialog select Pattern Block. For more information, see

Section 4.7.1, How to Use Advanced Mode Pattern Matching Options .

9. Click OK.

10. In the pattern select the first field. By default this field contains for each case

where , as shown in Figure 4–50 . Working with Rulesets and Rules 4-39 Figure 4–50 Adding an Advanced Pattern Match Option

11. Select the aggregate option. This adds the context sensitive fields for an aggregate,

as shown in Figure 4–51 . Figure 4–51 Using Aggregate Functions in a Rule

12. Click function and select a function from the list.

13. In the condition, click fact type and select a fact type from the list.

14. Click expression and select an expression from the list.

15. Rules Designer by default constructs variable names as you create the aggregate pattern. If needed for the rule you are constructing enter variable names to replace the default variable names. Figure 4–52 shows a completed rule using aggregate. In this example, for clarity the rule shows the variable names total_cost and item_x . 4-40 Oracle Fusion Middleware Users Guide for Oracle Business Rules Figure 4–52 Completed Aggregate Function in a Rule

16. Enter additional tests as required. For this example you enter the test for items