Sql 将两个不同的表计数插入配置单元表
我需要从两个不同的表计数向配置单元表中插入数据 例如,假设我有一个表Sql 将两个不同的表计数插入配置单元表,sql,hadoop,hive,hiveql,Sql,Hadoop,Hive,Hiveql,我需要从两个不同的表计数向配置单元表中插入数据 例如,假设我有一个表sample,其中包含字段counter1和counter2 现在我有另外两个表test1和test2 我需要在sample.counter1中插入test1的select count(*),在sample.counter2中插入test2的select count(*) 如果最终表中有一列,则它可以工作,如: insert into table sample select count(*) from test1 现在我需要插
sample
,其中包含字段counter1
和counter2
现在我有另外两个表test1
和test2
我需要在sample.counter1中插入test1的select count(*),在sample.counter2中插入test2的select count(*)
如果最终表中有一列,则它可以工作,如:
insert into table sample select count(*) from test1
现在我需要插入两列
有什么建议吗?这就是你想要的吗
insert into sample.counter1 (counter1, counter2)
select t1.cnt, t2.cnt
from (select count(*) as cnt from test1) t1 cross join
(select count(*) as cnt from test2) t2;
你好@Gordon Linoff,正在工作!,知道我是否有另一个字符串列以及查询是什么吗?@SatishKaruturi。您可以向选择中添加常量值。如果这不能回答你的问题,你应该问一个新问题,并附上适当的样本数据和期望的结果。