by gravypod · 8y ago · 0 comments
Their answer:
select age, sum(weight) as total_weight
from cats
group by age
having sum(weight) > 12;
Which is equivalent to: select age, sum(weight) as total_weight
from cats
group by age
having total_weight > 12;Also, optimisers aren't stupid, the actual sum() function will not be recalculated.
Answer from core PostgreSQL dev, Tom Lane