大数据学习——hive的sql练习题
ABC三个hive表 每个表中都只有一列int类型且列名相同,求三个表中互不重复的数
create table a(age int)
row format delimited
fields terminated by ','; create table b(age int)
row format delimited
fields terminated by ','; create table c(age int)
row format delimited
fields terminated by ','; a.txt
1
2
3
4
5
6
7
8
9 b.txt
2
3
11
12
14
15
16
18
35
6
7
8 c.txt
1
2
3
11
5
6
7
8
20
30
40
sql:
select * from (select a.* from a full outer join b on a.age=b.age full outer join c on a.age =c.age where (a.age is not null and b.age is null and c.age is null) or (b.age is not null and a.age is null and c.age is null) or (c.age is not null and a.age is null and b.age is null) union select b.* from b full outer join a on a.age=b.age full outer join c on b.age =c.age where (a.age is not null and b.age is null and c.age is null) or (b.age is not null and a.age is null and c.age is null) or (c.age is not null and a.age is null and b.age is null) union select c.* from c full outer join b on c.age=b.age full outer join a on a.age =c.age where (a.age is not null and b.age is null and c.age is null) or (b.age is not null and a.age is null and c.age is null) or (c.age is not null and a.age is null and b.age is null)) d where d.age is not null ;
运行结果:
sql:
select age,count(age) as c1 from (select age from a union all select age from b union all select age from c) t_union group by age having c1=1;
大数据学习——hive的sql练习题的更多相关文章
- 大数据学习——hive的sql练习
1新建一个数据库 create database db3; 2创建一个外部表 --外部表建表语句示例: create external table student_ext(Sno int,Sname ...
- 大数据学习资料之SQL与NOSQL数据库
这几年的大数据热潮带动了一激活了一大批hadoop学习爱好者.有自学hadoop的,有报名培训班学习的.所有接触过hadoop的人都知道,单独搭建hadoop里每个组建都需要运行环境.修改配置文件测试 ...
- 大数据学习——hive基本操作
1 建表 create table student(id int,name string ,age int) row format delimitedfields terminated by ','; ...
- 大数据学习——hive数据类型
1. hive的数据类型Hive的内置数据类型可以分为两大类:(1).基础数据类型:(2).复杂数据类型2. hive基本数据类型基础数据类型包括:TINYINT,SMALLINT,INT,BIGIN ...
- 大数据学习——hive函数
1 内置函数 测试各种内置函数的快捷方法: 1.创建一个dual表 create table dual(id string); 2.load一个文件(一行,一个空格)到dual表 3.select s ...
- 大数据学习——hive显示命令
show databases; desc t_partition001; desc extended t_partition002; desc formatted t_partition002; !c ...
- 大数据学习——hive使用
Hive交互shell bin/hive Hive JDBC服务 hive也可以启动为一个服务器,来对外提供 启动方式,(假如是在itcast01上): 启动为前台:bin/hiveserver2 启 ...
- 大数据学习——hive安装部署
1上传压缩包 2 解压 tar -zxvf apache-hive-1.2.1-bin.tar.gz -C apps 3 重命名 mv apache-hive-1.2.1-bin hive 4 设置环 ...
- 大数据学习——hive数仓DML和DDL操作
1 创建一个分区表 create table t_partition001(ip string,duration int) partitioned by(country string) row for ...
随机推荐
- 解析dynamic对象
最近做一个项目,需要解析由JSon转换过来的dynamic对象,JSon的解析可以直接使用fastJSon,但是如果不知道具体对象的话,后续的取值总是需要重复性的解析dynamic对象,很是麻烦,后来 ...
- 生产环境如何快速跟踪、分析、定位问题-Java
我相信做技术的都会遇到过这样的问题,生产环境服务遇到宕机的情况下如何去分析问题?比如说JVM内存爆掉.CPU持续高位运行.线程被夯住或线程deadlocks,面对这样的问题,如何在生产环境第一时间跟踪 ...
- IT人怎样防止过劳死?如何成为时间的主人?
投行的朋友还没走几天,搜狐的一位同胞又去了.又是过劳死! 每当读到这类新闻,IT人无不反镜自照,顾影自怜.无法拼爹拼钱的我们,似乎只有拼命了.生活好惨淡啊! 有人说:年轻人,悠着点儿!立刻 ...
- uvm_env——UVM大环境(UVM Environment )
1 What is uvm_env? uvm_env is used to create and connect the uvm_components like driver, monitors , ...
- JavaEE汇总
1.简述Spring. a) Spring是一个轻量级的控制反转(IoC)和面向切面(AOP)的容器框架,其目的是解决企业应用开发的复杂性,能够使用基本的JavaBean代替EJB,并提供了 ...
- C++拾遗(二)——初窥标准库类型
本篇博文的开始,先介绍一道书上看到的智力题:有20瓶药丸,其中19瓶装有1克/粒的药丸,余下一瓶装有1.1克/粒的药丸.有一台称重精准的天平,只是用一次天平的情况下如何找出比较重的那瓶药丸? 好了,直 ...
- 从零开发分布式数据库中间件 二、构建MyBatis的读写分离数据库中间件
在上一节 从零开发分布式数据库中间件 一.读写分离的数据库中间件 中,我们讲了如何通过ThreadLocal来指定每次访问的数据源,并通过jdbc的连接方式来切换数据源,那么这一节我们使用我们常用的数 ...
- wxwidgets编译及环境配置
wxwidgets编译及环境配置 安装步骤: 到www.CodeBlocks.org下载并安装CodeBlocks,最好下载MinGW版本的,可以省掉安装和配置GCC的麻烦. 到www.wxWidge ...
- 在Solr中配置中文分词IKAnalyzer
李克华 云计算高级群: 292870151 交流:Hadoop.NoSQL.分布式.lucene.solr.nutch 在Solr中配置中文分词IKAnalyzer 1.在配置文件schema.xml ...
- Cayley凯莱定理——一一对应
定理 过$n$个有标志顶点的树的数目等于$n^{n-2}$. 此定理说明用$n-1$条边将$n$个已知的顶点连接起来的连通图的个数是$n^{n-1}$.也可以这样理解,将n个城市连接起来的树状网络有$ ...