In this blog post, let’s learn about the error message “303 Expression mixes columns with aggregates.” in Hydra and the description of the error.
Error Message
303 Expression mixes columns with aggregates.
Error Details
This SELECT statement uses an aggregate function in its WHERE clause. This action is not allowed. The WHERE clause must be applied row by row as a table is scanned, but an aggregate function can only be calculated after all rows have been chosen and grouped. Review the statement with this fact in mind. If you intended to select only certain groups of records, you can put that test in the HAVING clause; it is applied to grouped rows.
The text of this message is somewhat deceptive. You can, in fact, mix column names and aggregate functions in expressions. However, you can do so only in the select list or the HAVING clause (not in the WHERE clause), and the columns must appear in the GROUP BY clause.
Database servers after Version 5.01 do not use this error message.
Leave a Reply