蜂巢从查询中排除值

时间:2018-09-05 18:19:24

标签: sql hive hiveql boolean-logic

我有一些看起来像

的数据
name        state
mary        florida
mary        NULL
john        alabama
mary        NULL
salt        texas

我想获取不包含状态为空的玛丽的结果。当我尝试

select name, state from my table where (state is not null and name = 'mary')

这只会给我所有与状态关联的玛丽。

我期望的结果是

name        state
mary        florida
john        alabama
salt        texas

1 个答案:

答案 0 :(得分:0)

选择除name ='mary'以外的所有其他项,并且状态为NULL:

System.Runtime.InteropServices.COMException: The filter does not exist. (Exception from HRESULT: 0x80320003) (Error code: 0x80320003 The filter does not exist 

或者根据De Morgan's law的相同(连接词的否定就是否定的析取):

select name, state from my table where NOT (state IS NULL AND name = 'mary');