Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 将两个不同的表计数插入配置单元表_Sql_Hadoop_Hive_Hiveql - Fatal编程技术网

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。您可以向
选择中添加常量值。如果这不能回答你的问题,你应该问一个新问题,并附上适当的样本数据和期望的结果。