Skip to content
Advertisement

Logic to use in place of Aggregate function the WHERE clause

I am computing the frequency of values over a large table. since the result of the aggregate functions result in zero for some rows, I would like to simply skip such rows. I could have used NULLIF(..) but I do not want to return a zero value. And aggregate functions aren’t allowed in the WHERE clause. How do I refactor the my query to skip such rows?.

Advertisement

Answer

You must use HAVING instead of WHERE for aggregate computations. For example:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement