如何检查BigQuery列表中是否有几个值

如何检查BigQuery列表中是否有几个值

本文介绍了如何检查BigQuery列表中是否有几个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使此子句更紧凑?

Is there a way to make this clause more compact?

SELECT campaign
       ,event_list
FROM `adobe_analytics.raw_data_20200*`
WHERE campaign IS NOT NULL  -- What does it mean when a campaign is null in Adobe_analytics
AND
(
"1" IN UNNEST(split(event_list,","))
OR "2" IN UNNEST(split(event_list,","))
OR "3" IN UNNEST(split(event_list,","))
)

类似的东西:

SELECT campaign
   ,event_list
FROM `adobe_analytics.raw_data_20200*`
WHERE campaign IS NOT NULL
AND ("1" OR "2" OR "3") IN UNNEST(split(event_list,","))

推荐答案

我会使用 exists :

SELECT campaign, event_list
FROM `adobe_analytics.raw_data_20200*` rd
WHERE campaign IS NOT NULL AND
      EXISTS (SELECT 1
              FROM UNNEST(SPLIT(rd.event_list)) el
              WHERE el IN ('1', '2', '3')
             );

这篇关于如何检查BigQuery列表中是否有几个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 11:46