SQL/MP Report Writer Guide
Table Of Contents
- What’s New in This Manual
- About This Manual
- 1 Introduction to the NonStop SQL/MP Report Writer
- 2 Using SQLCI and the Report Writer
- 3 Selecting Data for a Report
- 4 Customizing a Report
- Defining the Layout
- Specifying the Items in a Detail Line
- Naming Select List and Detail Line Items
- Organizing Rows Into Break Groups
- Labeling Information
- Formatting Data Values
- Formatting Dates and Times
- Using TACL to Pass Parameters
- Conditional Printing of Items or Line Entries
- Redefining Special Characters
- Calculating Totals
- Calculating Subtotals
- Printing Double-Byte Characters
- A Comparison of the Report Writer and the Enform Language
- Index
Selecting Data for a Report
HP NonStop SQL/MP Report Writer Guide—527213-001
3-34
Developing Multistep Queries
DEPTNUM DEPT_AVGSAL JOBCODE JOB_AVGSAL
------- ----------- ------- ----------
1000 52000 100 137000
500 34666
900 19000
1500 41250 100 90000
600 29000
900 17000
2000 50000 100 13800
200 24000
S>
The BREAK ON command suppresses printing of the same department number and
salary average in multiple lines. You can drop the tables or purge the data and reuse
the tables in future reports.
Conditional Aggregates
To produce a report that contains aggregate function values calculated for groups
selected by different WHERE clause criteria, use a multiple step query. For example,
assume that a report counts the number of employees whose salaries are in these
ranges:
Range 1 < 20000
Range 2 < 50000
Range 3 < 200000
The report contains one detail line for each department.
Follow these steps to create the report:
1. Create a temporary table for the report values. Define the RANGE
n columns with
the system default so you do not have to insert a value:
>> CREATE TABLE DEPTTEMP (
+> DEPTNUM NUMERIC (4) UNSIGNED NO DEFAULT,
+> RANGE1 INTEGER UNSIGNED DEFAULT SYSTEM,
+> RANGE2 INTEGER UNSIGNED DEFAULT SYSTEM,
+> RANGE3 INTEGER UNSIGNED DEFAULT SYSTEM )
+> CATALOG TEMPTABS ;
2. Insert the count for RANGE1 in the DEPTTEMP table:
>> INSERT INTO DEPTTEMP (DEPTNUM, RANGE1)
+> (SELECT DEPTNUM, COUNT(*) FROM PERSNL.EMPLOYEE
+> WHERE SALARY < 20000
+> GROUP BY DEPTNUM );
3. Enter two more INSERT commands to insert the counts for RANGE2 and
RANGE3. For each command, substitute RANGE2 or RANGE3 in the select list
and change the value in the WHERE clause to 50000 first and then to 200000.