8.3 Use the Data Wizard to Create Two Queries

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 Reports 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_Dept for the Query name and click Next.

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

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

    SELECT DEPARTMENT_ID, DEPARTMENT_NAME, LOCATION_ID
    FROM DEPARTMENTS
    

    Note:

    You can enter this query in any of the following ways:
    • Copy and paste the code from the provided text file called masterb_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.

  6. Click Next.

    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 8.1, "Prerequisites for This Example" describes the sample schema requirements for this example.
  7. On the Groups page, click Next.

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

  9. Repeat the steps above for a second query, but this time name your query Q_Emp and use the following SELECT statement:

    SELECT LAST_NAME, FIRST_NAME, JOB_ID, SALARY
    FROM EMPLOYEES
    ORDER BY LAST_NAME, FIRST_NAME
    

    Figure 8-3 Data model with two unrelated queries

    Description of Figure 8-3 follows
    Description of ''Figure 8-3 Data model with two unrelated queries''