1
我想从PostgreSQL中查询创建两个新的栏目,一个,另一个depnding对新列,即根据现有的数据创建依赖PostgreSQL的2分新的条件列
existing_col new_col new_col2
a 1 2
b 0 0
我曾尝试:
select existing_col,
case when existing_col like 'a' then 1 else 0 end as new_col
case when new_col like 1 then 2 else 0 end as new_col2
from table
但是,这是给我的错误,new_col不存在,我怎么能做到这一点?
你缺少'end'案例 –
有纠正错误仍然无效。 – user124123
您不能在引入别名的同一级别引用'new_col' –