【问题标题】:Metabase - Field Filter as text元数据库 - 作为文本的字段过滤器
【发布时间】:2021-04-11 15:36:01
【问题描述】:

我有这个 SQL 查询:

select concept, count(*)
from annotation
where exists (select 1
              from annotation a2
              where a2.comment_commentid = annotation.comment_commentid and a2.concept = 'Fatigue'
             )
group by concept;

我想用 {{word}} 替换“疲劳”,以做一个过滤器小部件,映射到数据库中的列。 我有以下错误:

错误:“=”位置或附近的语法错误:307

我需要改变什么来应用过滤器?从该列中选择可用的单词? 使用变量类型作为文本它可以工作......但不要在过滤器中显示所有可用选项,作为变量类型字段过滤器......

谢谢!

【问题讨论】:

    标签: sql postgresql data-visualization metabase


    【解决方案1】:

    outer annotation 表也需要别名。当有疑问时,inner 作用域总是在解析名称时占上风,inner exists(...) 也在作用域内查询 annotation 名称)

    [而你的错误原因很可能是中间件弄乱了]


    select concept, count(*)
    from annotation a1 -- <<-- HERE!
    where exists (select 1
                  from annotation a2
                  where a2.comment_commentid = a1.comment_commentid and a2.concept = 'Fatigue'
                 )
    group by concept;
    

    【讨论】:

    • 不处理 sql 问题...给出这个错误:ERROR: invalid reference to FROM-clause entry for table "annotation" Hint: Perhaps you meant to reference the table alias "a1". Position: 221
    • Perhaps you meant to reference the table alias "a1".
    猜你喜欢
    • 1970-01-01
    • 2022-10-31
    • 2014-09-09
    • 1970-01-01
    • 1970-01-01
    • 2015-02-07
    • 2019-05-29
    • 2019-03-03
    • 2017-09-26
    相关资源
    最近更新 更多