Click Close to close the Impact dialog when you have finished reviewing the
10-24 Oracle Fusion Middleware Administrators Guide for Oracle Business Intelligence Discoverer
views, one for each master-detail aggregation, and then combines the results of the outer query.
The following example shows the SQL that Discoverer uses to return the correct results:
SELECT inACC as Name, SUMinSalesSum as SALES_SUM, ,SUMinBudgetSum as BUDGET__ SUM,
FROM SELECT masterID AS OutMasterIDSales, SUMSalesDetailsSales AS inSalesSum
FROM SELECT ID AS masterID, NAME AS masterName FROM ACCOUNT INLineAccount,
SELECT ID AS SalesDetailId, ACCID AS SalesDetailAccID, SALES AS SalesDetailsSales FROM SALES INLineSales
WHEREmasterID = SalesDetailAccID+ GROUP BY masterID inner1,
SELECT masterID AS OutMasterIDBudget, SUMBudgetDetailBudget AS inBudgetSum, masterName AS inACC
FROM SELECT ID AS masterID, NAME AS masterName FROM ACCOUNT INLineAccount,
SELECT ID AS BudgetDetailId, ACCID AS BudgetDetailAccID, BUDGET AS BudgetDetailsSales FROM BUDGET INLineBudget
WHEREmasterID = BudgetDetailAccID+ GROUP BY masterName, masterID inner2
WHERE OutMasterIDBudget = OutMasterIDSales GROUP BY inACC
The result is correct because each sale and each budget is summed individually one for each master-detail aggregation and is then combined with a join based on the
master keys.
Producing incorrect results using a straightforward SQL statement
To answer the question, What is the total sales and total budget by account?, you might consider using a staightforward SQL statement such as the following:
SELECT Account.Name, SUMsales, SUMbudget FROM
Account, Sales, Budget Where
Account.id=Sales.accid AND
Account.id=Budget.accid GROUP BY
Account.Name
This straightforward SQL statement returns incorrect results, as shown below:
Although the results are relationally correct, they are obviously wrong. For example, the results indicate that the total sales figure for Account 1 is 800 but you can see from
the SALES table that the total sales figure for Account 1 is 400 that is, 100+100+200.
Account Sales
Budget
Account 1 800
1200 Account 2
130 200
Account 3 600
750 Account 4
600 600
Creating and Maintaining Joins 10-25
The incorrect results are based on a single query in which the tables are first joined together in a temporary table, and then the aggregation is performed. However, this
approach causes the aggregates to be summed incorrectly multiple times.
What to do if you set up a fan trap inside a complex folder
Discoverer warns about fan trap join configurations in complex folders by displaying a message indicating that an invalid join configuration exists. To make sure that
Discoverer returns correct results for complex folders, you can edit the Formula property of the detail item and explicitly specify the aggregate formula.
For example, you might set the Formula property of a Sales item in a complex folder, from Sales Fact.Sales to SUMSales Facts.Sales, as shown below:
Figure 10–19 Example of an aggregate formula specified for an item in a complex folder
What to do if you have a data type mismatch in a join
Discoverer does not allow joins between items of different data types for example, varchar, numeric, or date. However, if you have upgraded from a previous version of
Discoverer, an existing join might already exist between mismatched data types. If a join exists between two items with mismatched data types, Discoverer runs the query
but displays an error message and does not complete the query. Discoverer also displays an error message if you try to edit a join that contains items that have
mismatched data types.
You can create a join between two items that have mismatched data types by following the steps below:
■
create a new item based on the first mismatched item and use conversion functions for example, to_char, to_date, to_number to make the new item’s
data type compatible with the second item
■
create a join between the new item and the second item For more information, see
Example of how to create a join between two items that have mismatched data types
.
10-26 Oracle Fusion Middleware Administrators Guide for Oracle Business Intelligence Discoverer
Example of how to create a join between two items that have mismatched data types
In this example, you want to create a join between the Calendar Date folder and the Store and Sales Detail folder, using:
■
the Day of Week item from the Calendar Date folder
■
the Transaction Date item from the Store and Sales Detail folder These two items have mismatched data types, as follows:
■
the Day of Week item’s data type is varchar
■
the Transaction Date item’s data type is date To create a join between the two folders using these two items, you must perform the
following steps:
■
Step 1: Create a new item that converts the Day of Week item from a varchar to a date data type
■
Step 2: Create a join using the new item
Step 1: Create a new item that converts the Day of Week item from a varchar to a date data type
The first step is to create a new item that converts the Day of Week item from varchar to a date data type as follows: