Francisco Grau <grau(dot)fran(at)gmail(dot)com> writes:
> That makes perfect sense. It is weird that it works using the CTE though.
Well, the CTE forces single evaluation, so that the value is a constant
again from the outer query's perspective.
regards, tom lane