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练习题的更多相关文章

  1. 大数据学习——hive的sql练习

    1新建一个数据库 create database db3; 2创建一个外部表 --外部表建表语句示例: create external table student_ext(Sno int,Sname ...

  2. 大数据学习资料之SQL与NOSQL数据库

    这几年的大数据热潮带动了一激活了一大批hadoop学习爱好者.有自学hadoop的,有报名培训班学习的.所有接触过hadoop的人都知道,单独搭建hadoop里每个组建都需要运行环境.修改配置文件测试 ...

  3. 大数据学习——hive基本操作

    1 建表 create table student(id int,name string ,age int) row format delimitedfields terminated by ','; ...

  4. 大数据学习——hive数据类型

    1. hive的数据类型Hive的内置数据类型可以分为两大类:(1).基础数据类型:(2).复杂数据类型2. hive基本数据类型基础数据类型包括:TINYINT,SMALLINT,INT,BIGIN ...

  5. 大数据学习——hive函数

    1 内置函数 测试各种内置函数的快捷方法: 1.创建一个dual表 create table dual(id string); 2.load一个文件(一行,一个空格)到dual表 3.select s ...

  6. 大数据学习——hive显示命令

    show databases; desc t_partition001; desc extended t_partition002; desc formatted t_partition002; !c ...

  7. 大数据学习——hive使用

    Hive交互shell bin/hive Hive JDBC服务 hive也可以启动为一个服务器,来对外提供 启动方式,(假如是在itcast01上): 启动为前台:bin/hiveserver2 启 ...

  8. 大数据学习——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 设置环 ...

  9. 大数据学习——hive数仓DML和DDL操作

    1 创建一个分区表 create table t_partition001(ip string,duration int) partitioned by(country string) row for ...

随机推荐

  1. VS2015 VB.Net利用QrCodeNet生成QR Code

    Step by step Create QR Code with QrCodeNet Step.1 新建項目 Step.2 下載QrCodeNet代碼,解壓\QrCodeNet\sourceCode\ ...

  2. ajax传给springMVC数据编码集问题

    前台 ajax: $.ajax("${pageContext.request.contextPath}/hello",// 发送请求的URL字符串. { dataType : &q ...

  3. vue使用echarts可视化图形插件

    1.安装echarts:  cnpm/npm i echarts -S 2.main.js中   import echarts from 'echart'    Vue.prototype.$echa ...

  4. 51nod 1089 最长回文子串 V2(Manacher算法)

    基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 输入N求N的阶乘的10进制表示的长度.例如6! = 720,长度为3.   Input 第1行:一个数T,表示后面用作输入 ...

  5. The Django Book - 第四章 模板

    使用模板的最基本方式:1.根据原始模板代码字符串创建一个Template对象2. 使用字典创建一套Context变量3. 调用Template对象的render方法,传入Context变量参数 In ...

  6. UVA Live 3713 Astronauts (2-SAT)

    用布尔变量表示状态,把限制条件转化为XνY的形式以后跑2SAT,根据变量取值输出方案. #include<bits/stdc++.h> using namespace std; ; #de ...

  7. Android(java)学习笔记151:Android中操作JSON数据(Json和Jsonarray)

    1.Json 和 Xml       JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式.它基于ECMAScript的一个子集. JSON采用完全独立于语言的 ...

  8. JAVA 配置

    JAVA 版本为jdk-7u25-windows-x64 Java 下载地址为: .CLASSPATH .;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.j ...

  9. django 第一次运行出错

    直接运行整个项目正常,直接运行url文件报错 报错内容: E:\Python\python.exe D:/Python储存文件/ceshiweb/ceshiweb/urls.pyTraceback ( ...

  10. Android之父Andy Rubin:被乔布斯羡慕嫉妒的天才

    今年中国掀起一股“苹果热”,智能手机iPhone.平板电脑iPad遭疯抢,一度卖断货.然而,令许多人意想不到的是,在“苹果”的老家——美国市场,智能手机中卖得最火的并不是iPhone,而是Androi ...