设为首页 加入收藏

TOP

hive select查询语句
2018-12-05 01:11:47 】 浏览:97
Tags:hive select 查询 语句

hive select查询语句

现在不想整理了!!!!!!!!!有空再整理了!!!

SELECT [ALL | DISTINCT] select_expr, select_expr, ...

FROM table_reference
[WHERE where_condition]
[GROUP BY col_list]
[LIMIT number]


eg:
select empno, count from db_hive_emp limit 5 ;
limit:
从查询分析的结果集中显示多少条数据。


>>>>>>>>
全表查询、指定字段查询
use db_hive_0927 ;
select * from emp ; -- 不跑mr任务
select empno, ename, deptno from emp ; --执行mr任务


>>>>>>>>
= />= / <= /between and /limit
select empno, ename, deptno from emp where empno >= 7782 ;
select * from emp limit 5 ;
查询emp中工资在800 到 1500 之间的人
select ename, sal from emp where sal between 800 and 1500 ;


>>>>>>>>>>
(not) in / is (not) null
select ename, sal, comm from emp where comm is null ;
select ename, sal, comm from emp where comm is not null ;


>>>>>>>>>
max/min/count/sum/avg
select count(*) from emp ;
select count(1) from emp ;
select max(sal) max_sal from emp ;
select avg(sal) avg_sal from emp ;


>>>>>>>>>
group by / having
select deptno ,count(1) cnt from emp group by deptno ;


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


having 是对分组结果进行筛选的
select deptno ,avg(sal) avg_sal from emp group by deptno having avg_sal > 2000 ;
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Hive的字符串函数 下一篇Hive计算日期差

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目