hive中数据去重,union,交集和并集等操作语句总结
2017-01-23 10:59
2416 查看
insert overwrite table store
select t.p_key,t.sort_word from
( select p_key,
sort_word ,
row_number() over(distribute by p_key sort by sort_word) as rn
from store) t
where t.rn=1;
Hive上一个典型表内除重的写法, p_key为除重依据, sort_word 为排序依据,一般为时间 rn为排名。 这里就留下第一名
注意hql 方言中, 表的嵌套要家别名, 字段前加上表别名。 union all 不支持顶层视图。
参考链接:
hive 嵌套使用: http://www.oschina.net/code/snippet_1421929_43903
hive求两个集合的减集: http://www.bkjia.com/yjs/942686.html
SQL 操作结果集 -并集、差集、交集、结果集排序:http://www.cnblogs.com/kissdodog/archive/2013/06/24/3152743.html
关于hive子查询,union,left join :http://www.tuicool.com/articles/MZf6ny
hivejoin 操作小结: http://blog.csdn.net/xyilu/article/details/8112747
select t.p_key,t.sort_word from
( select p_key,
sort_word ,
row_number() over(distribute by p_key sort by sort_word) as rn
from store) t
where t.rn=1;
Hive上一个典型表内除重的写法, p_key为除重依据, sort_word 为排序依据,一般为时间 rn为排名。 这里就留下第一名
注意hql 方言中, 表的嵌套要家别名, 字段前加上表别名。 union all 不支持顶层视图。
参考链接:
hive 嵌套使用: http://www.oschina.net/code/snippet_1421929_43903
hive求两个集合的减集: http://www.bkjia.com/yjs/942686.html
SQL 操作结果集 -并集、差集、交集、结果集排序:http://www.cnblogs.com/kissdodog/archive/2013/06/24/3152743.html
关于hive子查询,union,left join :http://www.tuicool.com/articles/MZf6ny
hivejoin 操作小结: http://blog.csdn.net/xyilu/article/details/8112747
相关文章推荐
- 分享Hive的一份胶片资料
- Hadoop生态上几个技术的关系与区别:hive、pig、hbase 关系与区别
- sql server几种Join的区别测试方法
- MySQL中join语句的基本使用教程及其字段对性能的影响
- SQL JOIN 连接详细介绍及简单使用实例
- SQL 外链接操作小结 inner join left join right join
- SQL语句的并集UNION 交集JOIN(内连接,外连接)等介绍
- mysql 开发技巧之JOIN 更新和数据查重/去重
- 浅谈SQL Server中的三种物理连接操作(性能比较)
- oracle中left join和right join的区别浅谈
- MySQL JOIN之完全用法
- mysql多表join时候update更新数据的方法
- SQL中的left join right join
- SQL的Join使用图解教程
- SQL Join的一些总结(实例)
- union这个连接是有什么用的和INNER JOIN有什么区别
- python分割和拼接字符串
- C#多线程之Thread中Thread.Join()函数用法分析
- JavaScript中join()方法的使用简介
- MySQL中Nested-Loop Join算法小结