2

I've a field with tow distinct string foo and bar. I want to create a new calculated metrics based on this field where I only count the number of foo string. how do I do that ?

So far I've tried this but doesn't work :

COUNT(CASE WHEN REGEXP_MATCH(type,'foo.*'))

Not sure if my question is clear. please tell me if it's not.

Edit : I found this solution SUM(CASE WHEN Type = 'foo' THEN 1 ELSE 0 END) however I would love to know how to solve this issue with Regexp

4

1 に答える 1

2

にはREGEXP_MATCH完全な文字列一致が必要です。

REGEXP_MATCHfield_expressionに含まれる文字列全体との一致を試みます。たとえば、field_expression が "ABC123" の場合:
REGEXP_MATCH(field_expression, 'A')false を返します。
REGEXP_MATCH(field_expression, 'A.*')true を返します。

したがって、 を含む文字列を見つけるには、次をfoo使用します。

REGEXP_MATCH(type,'.*foo.*')
于 2016-10-28T17:03:13.920 に答える