我想从BigQuery表获取记录,该表至少具有两个所需值之一

时间:2019-01-10 15:27:26

标签: sql google-bigquery

我的BigQuery架构应该 company_name | email | email_2 | phone | mobile |,该表中大约有5万条记录。 我想获取至少提及电话号码和电子邮件的记录。 需要与 例如。 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);

2 个答案:

答案 0 :(得分:2)

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

Given I login using the users:
|url    |userRole       |
|http://localhost:3000  |Administrator  |
|http://localhost:3000  |User           |

答案 1 :(得分:2)

我认为以下是最紧凑和可扩展的(就涉及的列数而言)-适用于BigQuery Standard SQL

#standardSQL
SELECT *
FROM `project.Property_Dataset.pmDATA`
WHERE NOT COALESCE(email, email_2) IS NULL
AND NOT COALESCE(phone, mobile) IS NULL