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. 如何在spring环境中做单元测试

    在测试类的上方加入以下注解 @RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration("classpath:spring.xm ...

  2. Apache的多处理模块MPM

    本博文主要参数 Apache 2.2文档以及Apache模块开发指南 Apache的整个运行可以分为两个阶段:启动阶段和运行阶段. 在启动阶段时,它以ROOT特权来启动,进行解析配置文件(一般就是ht ...

  3. net core 在docker(ubuntu)部署

    1.vs新建项目并发布,然后copy到linux系统上,我这里是用的虚拟机. 2 Dockerfile文件配置 FROM microsoft/dotnet:2.1-aspnetcore-runtime ...

  4. eCharts基础知识

    eCharts插件介绍 http://echarts.baidu.com/tutorial.html#ECharts%20%E7%89%B9%E6%80%A7%E4%BB%8B%E7%BB%8D

  5. html5.0学习记录(一)——可拖动视频播放器

    最近自己在重新学习html5新特性,了解到有视频标签和拖动标签,于是自己用这两个特性写了一个小demo,主要功能就是可以通过拖动视频来直接播放.效果图如下: 页面使用了<video>标签和 ...

  6. Azure CLI 2.0-Azure新命令行工具介绍

    Azure CLI 2.0 是 Azure 的新命令行体验,用于管理 Azure 资源. 可以将其安装在 macOS.Linux 和 Windows 上,然后从命令行运行它. Azure CLI 2. ...

  7. VS2010中C++ 出现fatal error LNK1169: 找到一个或多个多重定义的符号

    一般是函数重定义造成的 例如定义了两个 sum(x,y)函数

  8. Git服务器和Git权限管理应用GITLAB安装方法

    首先声明,本文使用的服务器是Centos 6.5,在其他版本的LINUX上运行不保证也是一样的效果. 顺便说下 来波点赞 来波收藏和推荐  有什么问题 我会一直关注评论的 想放一张最终图吧 其中主要涉 ...

  9. ubuntu 14.04 安装npm

    1. 安装 sudo apt install nodejs-legacy sudo apt install npm  

  10. 分布式文件系统ceph介绍

    ceph哲学思想 1. 每个组件必须支持扩展 2.不存在单点故障 3.解决方案必须是基于软件的.开源的.适应能力强 4.任何可能的一切必须自我管理 存在的意义:帮助企业摆脱昂贵的专属硬件 ceph目标 ...