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:
If there is no GROUP BY clause, only aggregate functions may be selected in queries that include a HAVING clause.