Robert Haas <robertmhaas@gmail.com> writes:
> You might find a sub-SELECT helpful:
> SELECT * FROM (SELECT json_data->>’plan'->>’id' as plan_id FROM
> orders) x WHERE plan_id = 1
> It might be a generally useful thing for WHERE-clause items to be able
> to reference items from the target list by alias, or maybe it's
> problematic for some reason that I don't know about,
Standards compliance? It's not just a trivial syntactic issue either,
but a rather fundamental conceptual one: expressions in the target list
are not supposed to be evaluated until after the WHERE clause is.
regards, tom lane