有人可以帮助我了解这里发生了什么吗?
SELECT
jsonb_array_length(to_jsonb("gi"."colors_distilled")) "gi_colors_distilled_jsonb_len"
FROM
"general_inventories" "gi"
WHERE
"gi_colors_distilled_jsonb_len" > 1;
失败:
-- ERROR: column "gi_colors_distilled_jsonb_len" does not exist
-- LINE 6: "gi_colors_distilled_jsonb_len" > 1;
然而,这是可行的(直接在条件内实现表达式):
SELECT
jsonb_array_length(to_jsonb("gi"."colors_distilled")) "gi_colors_distilled_jsonb_len"
FROM
"general_inventories" "gi"
WHERE
jsonb_array_length(to_jsonb("gi"."colors_distilled")) > 1;
感觉我一定错过了一些明显的东西,但那里的东西太少了,我一定是搞砸了关于如何/何时评估别名的假设。