根据另一个字段用例创建新字段 QGIS

Create New Field QGIS Depending on Another Field Using Case

我想在 QGIS 中创建一个依赖于另一个字段中包含的数据的新字段。

我正在使用字段计算器和 case 函数,但它似乎出于某种原因试图将我的条件字符串提取为字段!

它看起来像这样 - 我正在尝试根据现有的 LEASE 字段创建一个新字段,其值是 Interested 或 Toronto。

CASE 
when LEASE Like "Interested" or "Toronto" then "Participating" 
Else "Non-Participating" 
End 

我得到的错误是

Column Interested is not found

有什么想法吗?

双引号用于分隔标识符。对字符串文字使用单引号:

CASE 
when LEASE IN ('Interested', 'Toronto') then 'Participating'
Else 'Non-Participating'
End 

OR 部分已替换为 IN,以节省一些输入。你也可以做 when LEASE = 'Interested' OR LEASE = 'Toronto' then,但是 IN 更方便。