SQL/MP Query Guide
Retrieving Data: How to Write Queries
HP NonStop SQL/MP Query Guide—524488-003
1-8
Specifying Search Conditions
When evaluating the GROUP BY clause, SQL considers all null values to be equal.
The result can have at most one null group.
If a collation is specified as part of the GROUP BY clause in a SELECT statement, the
character set associated with the collation must be the same as the character set
associated with the column in the SELECT statement.
For more information about aggregate functions such as SUM, see Aggregate
Functions in Predicates on page 1-41. For more information about GROUP BY
operations, see How the Optimizer Processes Aggregates and Group-By Operations
on page 3-46.
Specifying Search Conditions
When you write a query, you can specify a set of conditions called search conditions
that restrict the amount of data retrieved from the database. Search conditions
determine which rows are returned in the result table.
A search condition consists of one or more subqueries and predicates, used together
as a single test for the data:
•
A subquery is a form of SELECT statement specified as part of a search condition.
Defining Subqueries on page 1-28 describes how to write queries that contain
subqueries.
•
A predicate is a condition that always evaluates to one of three values: true, false,
or unknown (if not enough information is known by SQL to return true or false).
SQL returns rows only if the predicate evaluates to true. Example 1-1 used a
predicate with the greater-than operator (>) to compare values in the table. For
more information, see Defining Predicates on page 1-30.
You can specify search conditions within these clauses of a SELECT statement:
•
WHERE clause
•
HAVING clause
•
ON clause in a SELECT statement involving a join operation
Example 1-5. SELECT Statement With GROUP BY Clause and SUM Function
SELECT PARTNUM, SUM (QTY_ORDERED) FROM ODETAIL
GROUP BY PARTNUM ;
PARTNUM (EXPR)
------- ----------
212 20
244 47
. .
. .
7301 96
--- 27 row(s) selected.










