+---------+-----------+--------+
| user_id | email | action |
+---------+-----------+--------+
| 1 | [email protected] | open |
+---------+-----------+--------+
| 2 | null | click |
+---------+-----------+--------+
| 3 | [email protected] | click |
+---------+-----------+--------+
| 4 | [email protected] | open |
+---------+-----------+--------+
表2
+---------+-----------+--------+
| user_id | email | event |
+---------+-----------+--------+
| 1 | [email protected] | sent |
+---------+-----------+--------+
| null | [email protected] | none |
+---------+-----------+--------+
| 2 | [email protected] | sent |
+---------+-----------+--------+
| 4 | [email protected] | sent |
+---------+-----------+--------+
我想根據加入t1.user_id = t2.user_id,但是當有一個空的鍵,加入上t1.email = t2.email
我嘗試多種方式在BigQuery中加入如:
1)ON COALESCE(t1.user_id,t1.email)= COALESCE(t2.user_id,T2。電子郵件)
2.)ON在t2.user_id不爲空的情況下,則t1.user_id = t2.user_id else t1.email = t2.email end
兩者都不工作。如何才能做到這一點?
SQL具有「顯「和」不是DISTINCT「,但我在BigQuery中看不到。 –