【问题标题】:Create New Field QGIS Depending on Another Field Using Case使用案例根据另一个字段创建新字段 QGIS
【发布时间】:2017-10-17 15:15:37
【问题描述】:

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

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

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

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

我得到的错误是

未找到感兴趣的列

有什么想法吗?

【问题讨论】:

  • 双引号用于分隔标识符,例如"ColumnName"。对字符串文字使用单引号,例如'Interested'.
  • ... when LEASE IN ('Interested', 'Toronto') then...
  • 感谢您的帮助 - 但是,当我以这种方式更新时,它现在显示“无法将 'Toronto' 转换为布尔值”。编辑:Jarlh 的上述功能解决了这个问题。
  • 这就是为什么你应该改用IN (...)

标签: sql case field calculator qgis


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 2016-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多