I want to reuse an expensive function call in PostgreSQL:
SELECT name,
expensive_function(bar) as bars,
array_length(bars) as total
FROM foos
GROUP BY name
but of course bars isn't a column so the following error is raised:
ERROR: column "bars" does not exist
Is there a syntax or trick that will make this work?