大数据学习——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 ...
随机推荐
- Fabric 简单使用
Fabric 简单使用 最近公司组织压测系统,要在多台机子上部署代码,可是机子上的代码与生产环境不一样,需要修改代码,还有有问题的地方要修改,然后再发代码.这边一共有7台服务务器,重新发代码,要一台一 ...
- 什么是OOA/OOD
Object Oriented Analyzing Object Oriented Design Object Oriented Programming ooa(object oriented ana ...
- GraphicsMagick安装&make命令使用
0.0本过程为GraphicsMagick Linux版安装,通过典型的make编译安装. 未了支持png和jpg格式,首先请安装依赖.执行 yum install -y libpng-devel y ...
- https域名强弱校验的区别
HttpsURLConnection.setDefaultHostnameVerifier( new HostnameVerifier(){ public boolean verify(String ...
- 洛谷 2543 [AHOI2004]奇怪的字符串
题目描述 输入输出格式 输入格式: 输入文件中包含两个字符串X和Y.当中两字符串非0即1.序列长度均小于9999. 输出格式: X和Y的最长公共子序列长度. 输入输出样例 输入样例#1: 010101 ...
- bzip2命令
bzip2命令——压缩文件 命令所在路径:/usr/bin/bzip2 示例1: # bzip2 yum.log 压缩当前目录下yum.log文件成yum.log.bz2 示例2: # bzip2 - ...
- iPhone Tutorials
http://www.raywenderlich.com/tutorials This site contains a ton of fun written tutorials – so many t ...
- js 下载文件/导出
const url = '/sasd/fsd/xxxx/exportMailData2Excel'this.downloadFile(url, 'blob', this.isSearch) // 调用 ...
- Dijkstra算法——单源最短路算法
一.介绍 迪杰斯特拉(Dijkstra)算法是典型最短路径算法,用于计算一个节点到其他各个节点的最短路径. 它的主要特点是以起始点为中心向外层层扩展(广度优先搜索思想),直到扩展到终点为止. 适用于有 ...
- URL URI URN的区别
下面这张图可以完美的解释他们三者之间的关系 URI包含URL和URN Uniform Resource Identifier :统一资源标志符,用于标识某一互联网资源 Uniform Resoutce ...