Hive 比较两个列相同但数据值不同的配置单元表
一个数据库有两个表table1和table2。这两个表的结构相同 表1 姓名得分1分2分决赛 a 0 1 0 表2 姓名得分1分2分决赛 a 0 0 0 我想比较两个表,检查表2.score的值是否等于表1.score+2 我想让配置单元查询检查一下Hive 比较两个列相同但数据值不同的配置单元表,hive,Hive,一个数据库有两个表table1和table2。这两个表的结构相同 表1 姓名得分1分2分决赛 a 0 1 0 表2 姓名得分1分2分决赛 a 0 0 0 我想比较两个表,检查表2.score的值是否等于表1.score+2 我想让配置单元查询检查一下 enter code here select count(*) from test.table2 a, test.table1 b where a.score1='2' and a.score2='0' and b.score1='2' and
enter code here
select count(*)
from test.table2 a,
test.table1 b
where a.score1='2' and a.score2='0'
and b.score1='2' and b.score2='0'
and a.scorefinal=(b.scorefinal+2);
我想以更好的方式使用连接进行比较,如果可能的话select*from
选择*,
a.score1=b.score1或a.score2=b.score2或a.scorefinal=b.scorefinal+2时的情况
那么1
其他0
结束为值-在此处给出一个OR条件,这意味着如果其中任何一个为真,则为1,如果您需要在所有需要保留的情况下该条件为真,则为1
从
表2 a,
表1 b
q
其中value=1到目前为止您做了什么?