Previous Topic Next topic Print topic


Examples

Restriction: This topic applies to Windows environments only.

The query statement below would generate an error message because there is no GROUP BY clause that instructs the XDB Server to group records on the selected SNO column -- for purposes of calculating average quantities:

SELECT sno, AVG(qty)
FROM partsupp

The next query of the PARTSUPP table is corrected to include the GROUP BY clause:

SELECT sno, AVG(qty)
FROM partsupp
GROUP BY sno

The query results follow:

sno avg(qty)
S1 216.67
S2 350.00
S3 200.00
S4 300.00

If there is no GROUP BY clause, only aggregate functions may be selected in queries that include a HAVING clause.

Note: The GROUP BY and HAVING clauses are covered in Other Clauses. Aggregate functions are covered in Functions.
Previous Topic Next topic Print topic