Previous Topic: Add Single Entity ViewsNext Topic: Use Multiple Functions


Add Multiple Entity Views

You can add multiple entity views as discussed in the following example:

Multiple Entity Views with a Simple Relationship

Using an aggregate function with multiple views provides a result table or an intersection result table depending on the relationship specified in the WHERE clause between those views.

For example, to find the total number of classes attended by all the students, use a statement similar to the following example:

SUMMARIZE student 
class 
PLACING count(OCCURRENCES) INTO local ief_supplied count 
WHERE DESIRED student 
attends DESIRED class 

Note: When multiple entity views are included in the read list, each aggregate function in a PLACING clause reference the intersection table that results by joining their corresponding tables. Therefore, the number of occurrences in the result equal the product of the number of entities of each type that are selected. The joining of the tables occurs because of the relationships defined between the entities.

Related Entities Not in the Read List

To find the number of students that actually attend at least one class, use a statement similar to the following example:

SUMMARIZE student 
PLACING count(OCCURRENCES) 
INTO local ief_supplied count 
WHERE DESIRED student attends SOME class 

Note: The result table excludes entity views not in the entity view list. Relationships between DESIRED and SOME entity views do not create an intersection table.