SQL/MX Report Writer Guide

HP NonStop SQL/MX Report Writer Guide527194-002
3-1
3 Selecting Data for a Report
Before you can define a report, you must retrieve the data by entering a SELECT
command. The report formatting commands you specify refer to columns (or print
items) specified in the select list of the SELECT command.
The SELECT command selects the data that will be formatted by the report formatting
commands or will be displayed or printed in the default report format. For a complete
description of the SELECT command and all language elements of SQL, see the
SQL/MX Reference Manual. For a complete description of developing queries, see the
SQL/MX Query Guide.
Data Selection
This section discusses techniques for selecting data:
Developing a query
°
Determining which tables contain the data
°
Selecting the column values you need
°
Setting criteria for selecting rows
°
Sorting the data
Computing values based on column values from groups of rows: averages, sums,
minimums, maximums, and counts
Selecting rows with a distinct value in a column
Using expressions to calculate report item values
Using parameters to provide different selection criteria each time you produce a
report
Data Selection 3-1
Developing a Query 3-2
Joining Tables 3-4
Comparing a Set of Columns to a Set of Values 3-10
Comparing Character Values 3-11
Grouping Data for Calculations 3-16
Using Expressions to Calculate Report Values 3-22
Preparing a SELECT Command 3-25
Using Views 3-26
Using Subqueries 3-28
Developing Multistep Queries 3-32