BigQuery - 过滤而不会丢失' null'值

时间:2015-04-28 08:57:04

标签: null google-bigquery contains

我尝试过滤数据库,但不幸的是我失去了' null'值无论如何:

样本看起来像

Name | City | Sold
Nike | NYC  | 15
null | SFO  | 20
Mega | SEA  | 10
null | null | 8
nike | CHI  | 12

我尝试以任何方式编写没有Nike的数据,但是当我选择

Select ...
where not lower(Name) contains "nike"

然后我发现只有

  

Mega | SEA | 10

名称 null 值的所有行也都消失了。 如何防止删除? 感谢

1 个答案:

答案 0 :(得分:2)

见:

select * from 
(select string(NULL) as name,'SFO' as city, 20 as sold),
(select 'Nike' as name,'NYC' as city, 15 as sold),
where not lower(name) contains 'nike2' or name is null

返回

+-----+------+------+------+---+
| Row | name | city | sold |   |
+-----+------+------+------+---+
|   1 | null | SFO  |   20 |   |
|   2 | Nike | NYC  |   15 |   |
+-----+------+------+------+---+