Prerequisites for This Example Create a New Report Manually

Building a Group Left Summary Report 13-3

2. In the Welcome or New Report dialog box, select Build a new report manually,

then click OK.

13.3 Create a Data Model with a Data Link

When you create a report with multiple queries, it is typically easier to create all of the queries with the Data Wizard first and then create the layouts with the Report Wizard. To create the queries:

1. In the Data Model view, choose Insert Query to display the Data Wizard.

2. If the Welcome page displays, click Next.

3. On the Query page, type Q_Customer for the Query name, then click Next.

4. On the Data Source page, select SQL Query, then click Next.

5. On the Data page, enter the following SELECT statement in the Data Source

definition field: SELECT CUSTID, NAME FROM CUSTOMER ORDER BY NAME

6. Click Next.

7. On the Groups page, click Next.

8. Click Finish to display your first query in the Data Model view.

9. Repeat the steps above for a second query, but this time name your query Q_Item and use the following SELECT statement: SELECT CUSTID, DESCRIP, ITEMTOT, ORDERDATE, ITEM.ORDID FROM ORD, PRODUCT, ITEM WHERE ITEM.ORDID = ORD.ORDID AND ITEM.PRODID = PRODUCT.PRODID ORDER BY CUSTID, DESCRIP, ORDERDATE Note: You can enter this query in any of the following ways: ■ Copy and paste the code from the provided text file called grp_above_summ_code.txt into the Data Source definition field. ■ Click Query Builder to build the query without entering any code manually. ■ Type the code in the Data Source definition field. Note: If you are not already connected to a database, you will be prompted to connect to the database when you click Query Builder or Next. Ensure that you connect to a database that has the appropriate schema for this example. Section 13.1, Prerequisites for This Example describes the sample schema requirements for this example. 13-4 Oracle Reports Users Guide to Building Reports 10. On the Groups page of the Data Wizard: ■ Click CUSTID1 and click the right arrow to move this field to the Group Fields list. ■ Do the same for DESCRIP. Figure 13–2 Groups page of the Data Wizard

11. Click Next.

12. On the Totals page, click ITEMTOT and click Sum.

13. Click Finish to display the data model for your report in the Data Model view. It

should look something like this: Figure 13–3 Two-query data model with summaries To add the data link:

1. In the Data Model view, click the Data Link tool in the tool palette.

2. Click and drag from the CUSTID column in the G_CUSTID group to the

CUSTID1 column in the G_CUSTID1 group. Notice that a line is drawn from the