SQL/MP Report Writer Guide

Selecting Data for a Report
HP NonStop SQL/MP Report Writer Guide527213-001
3-2
Developing a Query
After you know what information you want, you can compose a SELECT command to
retrieve the data. The SELECT command must retrieve all the data you need, including
information in columns, titles, headings, and footings. In the following pages, one
approach to composing a SELECT command is presented.
Figure 3-1 illustrates the general content of a report on suppliers and the parts they
supply. The italicized words date and time, and the numbers below the column
headings are notes about what data is needed to produce the report.
Locating the Data
First, you must determine which database tables contain the data. The example in
Figure 3-1 uses data from the SUPPLIER, PARTSUPP, and PARTS tables. The report
contains the following data in the numbered output line items:
1 PARTS.PARTNUM
2 PARTS.QTY_AVAILABLE
3 PARTSUPP.PARTCOST
4 PARTSUPP.PARTCOST * PARTS.QTY_AVAILABLE
5 PARTS.QTY_AVAILABLE * (PARTS.PRICE - PARTSUPP.PARTCOST)
Each column name in this list is qualified by the name of the table that contains the
column. You can use the INVOKE command to determine the names of columns in a
table.
The report title includes the date and the time when the report is produced. These
values are to be provided through the CURRENT_TIMESTAMP function.