简体   繁体   English

在 Hive 中,if(field1=field2=field3=0,'0','1') 未给出预期结果

[英]In Hive, if(field1=field2=field3=0,'0','1') is not giving expected results

In Hive query, in the single IF condition, I provided multiple fields check, but not giving the expected results.在Hive查询中,在单IF条件下,我提供了多字段检查,但没有给出预期的结果。

Query:询问:

select ID, field1, field2, field3, 
       if(field1=field2=field3=0,'0','1') as compare_check
from input_table;

input_table输入表

输入表

Output results: Output 结果:

输出结果

Multiple conditions wont work here.多个条件在这里不起作用。 Could you please separate all conditions?你能把所有条件分开吗? Also make sure all fields doesn't have any extra space etc. around them.还要确保所有字段周围没有任何额外的空间等。

if(field1=field2 and field1=field3 
and field1=0,'0','1')

There is another way to do it -还有另一种方法 -

If (field1+field2+field3=0,0,1)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过Field1 Field2 Field3 ASC和DESC对查询结果进行排序 - Sort query results by Field1 Field2 Field3 ASC and DESC so Mysql在哪里查询…选择* where field1 + field2 + field3 &lt;=字段4 - Mysql where query… select * where field1 +field2 + field3 <= field 4 使用“SELECT Field1,Field2,Field3 ......”代替“SELECT * ...”可以获得性能提升吗? - Is there a performance gain achieved by using “SELECT Field1, Field2, Field3 …” instead of “SELECT * …” 从字段1,对应的字段2,GROUP BY字段3中查找MAX - Find MAX from field1, corresponding field2, GROUP BY field3 Select 其中 field1 或 field2 或 field3 等于电话号码 - Select where field1 or field2 or field3 is equal to a phone number 尝试将记录插入PostgreSQL数据库时出现“无效的组合字段1字段2字段3”错误消息 - “Invalid combination field1 field2 field3” error message while trying to insert record into postgresql database 从表中选择*或从表中选择id,field1,field2,field3 - 最佳实践? - Select * from table OR select id,field1, field2, field3 from table - best practice? 尝试在可能存在于Field1或Field2或Field3中的表中查找特定值…(依此类推) - Try to find a specific values in a table that can exist in Field1 or Field2 or Field3…(and so on) 在derby jdbc中是否支持类似“从A中选择field1,field2,field3,其中(从B中选择a,b)中的(a,b)”的语法? - Is syntax like “select field1,field2,field3 from A where (a,b) in (select a,b from B)” supported in derby jdbc? 参数化查询中的(?,?...?)或(@ field1,@ field2 ... @ fieldn)? - (?,?…?) or (@field1,@field2…@fieldn) in parmeterized queries?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM