首页 > 解决方案 > 我想从 BigQuery 表中获取至少具有两个所需值之一的记录

问题描述

我的 BigQuery 架构假设 company_name | email | email_2 | phone | mobile |并且表中有大约 50K 条记录。我想获取至少提到电话号码和电子邮件的记录。需要行与例如。 email phone email mobile
email_2 phone email_2 mobile email email_2 phone email email_2 phone mobile

什么是有效的代码,因为我是 SQL 和 BigQuery 的新手?

FROM Property_Dataset.pmDATA 
WHERE 
(email IS NOT NULL AND phone IS NOT NULL) OR
(email IS NOT NULL AND mobile IS NOT NULL) OR
(email_2 IS NOT NULL AND phone IS NOT NULL) OR
(email_2 IS NOT NULL AND mobile IS NOT NULL);

标签: sqlgoogle-bigquery

解决方案


我认为您可以使用如下的 where 子句:

select *
from Property_Dataset.pmDATA 
where (email is not null or email_2 is not null) AND (phone is not null or mobile is not null) 

推荐阅读