我正在尝试在 PostgreSQL 查询中使用CASE并在 where 或有条件的情况下使用它,我收到了这个错误消息
[Err] 错误:列“new_dismiss”不存在第 14 行:
trans_requistion_details.original_qty > new_dismiss
SELECT
*,
CASE
WHEN dismiss_qty is NULL THEN 0
ELSE dismiss_qty
END AS new_dismiss
FROM
trans_requistion_details
INNER JOIN sub_ingredients ON trans_requistion_details.sub_ing_id = sub_ingredients.sub_ing_id
INNER JOIN units ON sub_ingredients.sub_ing_stock_unit = units.unit_id
INNER JOIN ing_groups ON sub_ingredients.ing_group_id = ing_groups.ing_group_id
HAVING
trans_requistion_details.trans_id = 175991 and original_qty > new_dismiss