All expressions in
SelectItems in the
SelectExpression must
be either aggregates or grouped columns (see
GROUP BY clause).
(The same is true if there is a HAVING clause without a GROUP BY clause.)
This is because the
ResultSet of a
SelectExpression must
be either a scalar (single value) or a vector (multiple values), but not a
mixture of both. (Aggregates evaluate to a scalar value, and the reference
to a column can evaluate to a vector.) For example, the following query mixes
scalar and vector values and thus is not valid:
-- not valid
SELECT MIN(flying_time), flight_id
FROM Flights