我想通过以下查询
(statement1 AND statement2 AND (statement3 OR statement4 ))
这是我的hive查询,我验证它不起作用,因为它只返回statement3,我知道有些情况,其中statement4为true
SELECT
cid,
SUM(count) AS total_count
FROM
count_by_day
WHERE
time >= 1435536000
AND time < 1436140800
AND(
cid = '4eb3441f282d4d657a000016'
OR cid = '14ebe153121a863462300043d'
)
GROUP BY
cid
谁能告诉我有什么问题?谢谢
WHERE cast(time as bigint) >= 1435536000 AND cast(time as bigint) < 1436140800
SELECT
cid,
SUM(count) AS total_count
FROM
count_by_day
WHERE time >= 1435536000 AND time < 1436140800
AND cid in('4eb3441f282d4d657a000016','14ebe153121a863462300043d')
GROUP BY
cid;
一次尝试一次更改,以便了解修复的内容。
查询1:
Select A,B,C
From
Table1 t1
Join
Table2 t2
On
T1.field1=T2.field1 OR
T1.field2 = T2.field2
QUERY2:
Select A,B,C
From
Table1 t1
Join
Table2 t2
On
T1.field1=T2.field1
Union
Select A,B,C
From
Table1 t1
Join
Table2 t2
On
T1.field2 = T2.field2
始终学会在关系数据库中使用UNION而不是OR。试试看联盟是否解决了你的问题。
select cols
from table
where statement1 AND statement2 AND statement3
union all
select cols
from table
where statement1 AND statement2 AND statement4