Create a new report manually Create a data model with a cross product and data links

Building a Nested Matrix Report 26-7 SELECT DISTINCT JOB FROM EMP 11. Again, repeat the steps above for a fourth query, but this time name your query Q_ Salary and use the following SELECT statement: SELECT TO_CHARHIREDATE, YY YEAR, DEPTNO, JOB, SUMSAL FROM EMP GROUP BY TO_CHARHIREDATE, YY, DEPTNO, JOB ORDER BY TO_CHARHIREDATE, YY, DEPTNO, JOB Figure 26–5 Data model with four queries To create the cross product group: 1. In the Data Model view, click the Cross Product tool in the tool palette.

2. Drag a box around G_YEAR, G_DEPTNO, and G_JOB. When you release the

mouse button, the cross product group is created. Ensure that it completely surrounds all three groups. Tip: The order of the queries is significant in this case. Q_Dept must appear to the right of or below Q_Year in order for the values of DEPTNO to be nested inside of the values of YEAR in the output. 26-8 Oracle Reports Users Guide to Building Reports Figure 26–6 Data Model with four queries and a cross product group To add the data links: 1. In the Data Model view, click the Data Link tool in the tool palette.

2. Click and drag from the YEAR column in the G_YEAR group to the YEAR1

column in the G_YEAR1 group. 3. Repeat steps 1 and 2, but this time drag the link between the DEPTNO column in G_DEPTNO and DEPTNO1 in G_YEAR1. 4. Again, repeat steps 1 and 2, but this time drag the link between the JOB column in G_JOB and JOB1 in G_YEAR1. Figure 26–7 Nested matrix data model 5. Optionally, move the data model objects around to appear like the above figure.

26.3.3 Create the layout with the Report Wizard

Once your data model is complete, you need to create a layout for the data objects to display in the report output. To create the layout:

1. In the Data Model view, right-click on the canvas, then choose Report Wizard.

2. In the Report Wizard, on the Report Type page, select Create Paper Layout only.

Building a Nested Matrix Report 26-9

3. On the Style page, select Matrix.

4. On the Groups page, ensure that all of the groups from your data model appear in

the Displayed Groups list. G_1 should be Matrix, G_YEAR and G_DEPTNO should be Down, G_JOB should be Across, and G_YEAR1 should be Down. Figure 26–8 Groups page of the Report Wizard

5. On the Fields page, ensure that only the following columns appear in the

Displayed Fields list: ■ YEAR ■ DEPTNO ■ JOB ■ SUM_SAL Figure 26–9 Fields page of the Report Wizard

6. On the Labels page, change the labels and field widths as follows:

26-10 Oracle Reports Users Guide to Building Reports

7. On the Template page, make sure Beige is selected under Predefined Template,

then click Finish to display your report output in the Paper Design view. It should look like this: Figure 26–10 Paper Design view for the nested matrix output

26.4 Create a Multiple-Query Matrix with a Break

If you compare the single-query nested matrix output in Figure 26–4, Paper Design view for the nested matrix report to the multiple-query output in Figure 26–10, Paper Design view for the nested matrix output , you notice that the multiple-query case displays all of the departments for every year while the single-query case does not. In the single-query case, only those departments that actually have values in their matrix cells are displayed in the output. To achieve a similar result with multiple queries, you need to have a parentchild relationship between the groups containing YEAR and DEPTNO.

26.4.1 Create a new report manually

In this case, it is easier to create the data model and layout separately. Hence, we will create an empty report first, then add the queries, and then create the layouts. To create a blank report:

1. Choose File New Report.

2. Select Build a new report manually, then click OK.

26.4.2 Create a data model with a cross product and data links

When you create a matrix report with multiple queries, it is typically easier to create all of the queries with the Data Wizard first and then create the cross product group and the necessary links in the Data Model view. Fields Labels Width SUM_SAL none 10 YEAR none 4 JOB none 10