1.字段查询

  select empno,ename from emp;

2.过滤where,limit,distinct

  select * from emp where sal >2500;

  

  select * from emp limit 2;

  

  select distinct deptno from emp;

  

3.过滤between and,is null

  select * from emp where sal between 2000 and 3000;

  

  

  select * from emp where comm is null;

  

4.聚合函数count,sum,avg,max,min

  select count(1) from emp;

  

  select avg(sal) avg_sal from emp;

  

5.group by,having

  要求:求每个部门的平均工资

  select deptno,avg(sal) from emp group by deptno;

  

  要求:部门平均工资大于2000的部门。

  select deptno,avg(sal) avg_sal from emp group by deptno having avg_sal>2000;

  

6.join 

  -》展示emp中的数据

         

  -》等值join:匹配连接字段两边共有的值
    select e.empno,e.ename ,d.deptno ,e.sal from emp e join dept d on e.deptno=d.deptno;

    

  -》左join left:以左边的该字段的值为标准
    select e.empno,e.ename ,d.deptno ,e.sal from emp e left join dept d on e.deptno=d.deptno;

   

  -》右join right:以右边的该字段的值为标准
    select e.empno,e.ename ,d.deptno ,e.sal from emp e right join dept d on e.deptno=d.deptno;

    

  -》全join full:以两张表中连接字段的所有值
    select e.empno,e.ename ,d.deptno ,e.sal from emp e full join dept d on e.deptno=d.deptno;

    

  

  

043 HIVE中的HQL操作的更多相关文章

  1. HIVE中的HQL操作

    1.字段查询 select empno,ename from emp; 2.过滤where,limit,distinct select * from emp where sal >2500; s ...

  2. Hive中运行HQL语句错误

    错误:org.apache.hadoop.yarn.exceptions.InvalidAuxServiceException( 或者为FAILED: Execution Error, return ...

  3. hive中执行hql或建表语句时,抛出Display all 459 possibilities? (y or n)错误的解决方法

    我昨天在hive上建表,一直报Display all 459 possibilities? (y or n) ,之前我以为是建表语句有问题,一直在改语句,后来在网上搜这个错误,原来语句里混杂了Tab缩 ...

  4. [Hive_7] Hive 中的 DDL 操作

    0. 说明 DDL(Data Definition Languages)语句:数据定义语言 这些语句定义了不同的数据段.数据库.表.列.索引等数据库对象的定义. 常用的语句关键字主要包括 create ...

  5. Hive中的用户自定义函数

    1.1 关于自定义函数 1)Hive 自带了一些函数,比如:max/min等,但是数量有限,自己可以通过自定义UDF来方便的扩展. 2)当Hive提供的内置函数无法满足你的业务处理需要时,此时就可以考 ...

  6. 使用Hive或Impala执行SQL语句,对存储在HBase中的数据操作

    CSSDesk body { background-color: #2574b0; } /*! zybuluo */ article,aside,details,figcaption,figure,f ...

  7. 使用Hive或Impala执行SQL语句,对存储在Elasticsearch中的数据操作(二)

    CSSDesk body { background-color: #2574b0; } /*! zybuluo */ article,aside,details,figcaption,figure,f ...

  8. 使用Hive或Impala执行SQL语句,对存储在Elasticsearch中的数据操作

    http://www.cnblogs.com/wgp13x/p/4934521.html 内容一样,样式好的版本. 使用Hive或Impala执行SQL语句,对存储在Elasticsearch中的数据 ...

  9. hive中的子查询改join操作(转)

    这些子查询在oracle和mysql等数据库中都能执行,但是在hive中却不支持,但是我们可以把这些查询语句改为join操作: -- 1.子查询 select * from A a where a.u ...

随机推荐

  1. sql工具和手工注入总结

    普通注入: 数字注入 字符注入 base64注入:和常规的方法没有说明区别,主要是解码然后编码: 如果普通注入不行,尝试大小写绕过,编码等绕过: 如果不行尝试盲注: POST注入 0x00 常用的 注 ...

  2. 实现一个string类

    实现要实现:构造,析构,拷贝构造,赋值的功能 1. 提供构造函数 string(), string(const string & str),string(const  char * str), ...

  3. XML之Well-Formed文档规则

    由于课程原因,近日粗略学习XML,载以博客是为担心忘记,以供日后复习之用. XML标准中明确规定了XML文件应当遵守的规则,大致上分成基本规则和DTD(Document Type Definition ...

  4. Python中crypto模块进行AES加密和解密

    #coding: utf8 import sys from Crypto.Cipher import AES from binascii import b2a_hex, a2b_hex class p ...

  5. hdp3: regionserver running as process 3170. Stop it first.

    1 启动hbase报错 hdp3: regionserver running as process 3170. Stop it first. 2 始终没有发现错误日志 3 jps没有发现hbase的r ...

  6. Django-Model操作数据库(增删改查、连表结构)

    一.数据库操作 1.创建model表         基本结构 1 2 3 4 5 6 from django.db import models     class userinfo(models.M ...

  7. linux bash的重定向

    cnblogs原创 下面几种bash重定向各表示什么意思? find / -name passwd > /dev/null >& > /dev/null find / -na ...

  8. MR架构

    MapReduce框架结构 Map/Reduce是一个用于大规模数据处理的分布式计算模型,它最初是由Google工程师设计并实现的,Google已经将它完整的MapReduce论文公开发布了.其中对它 ...

  9. linux关机时候执行命令脚本或程序

    Write a service file and place it in /etc/systemd/system/beforeshuttingdown.service code: [Unit] Des ...

  10. eclipse指定项目编译级别

    指定项目编译级别Eclipse→Preferences→Java→Compiler→Compiler compliance level:1.6或其他 或者,