Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/72.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_Hive_Hiveql - Fatal编程技术网

Sql 配置单元:识别准确的重复记录

Sql 配置单元:识别准确的重复记录,sql,hive,hiveql,Sql,Hive,Hiveql,我有一个要求 我有一个蜂巢表,它有200多列 现在,我必须编写一个insert查询,以便在删除所有相同的重复记录后将数据加载到另一个配置单元表中 我知道我可以通过在()上使用行号()来实现它 代码片段 Insert into table target Select col1,col2..col200 from ( Select col1,col2...col200,row_number () over ( partition by col1,col2...col200 order by nu

我有一个要求

我有一个蜂巢表,它有200多列

现在,我必须编写一个insert查询,以便在删除所有相同的重复记录后将数据加载到另一个配置单元表中

我知道我可以通过在()上使用行号()来实现它

代码片段

Insert into table target 
Select col1,col2..col200 
from
(
Select col1,col2...col200,row_number () over ( partition by col1,col2...col200 order by null ) as rn from source 
) a 
where 
rn=1
但这将非常冗长,因为需要多次编写所有200列的名称

有没有更简单的解决方案


谢谢您的建议。

您可以使用
选择distinct

Insert into table target 
    Select distinct col1,col2..col200 
    from source ;

您可以使用
选择不同的

Insert into table target 
    Select distinct col1,col2..col200 
    from source ;

非常感谢。如果我需要做一个分区col1 col2到col199..有没有更简单的选择来代替在分区中写199 colby@Queryguy . . . 如果它们都是列,您可以使用
*
。谢谢。如果我需要做一个分区col1 col2到col199..有没有更简单的选择来代替在分区中写199 colby@Queryguy . . . 如果它们都是列,则可以使用
*