HIVE点滴:group by和distinct语句的执行顺序
来源:互联网 发布:淘宝直通车玉女剑法 编辑:程序博客网 时间:2024/05/17 01:45
同一条语句之中,如果同时有group by和distinct语句,是先group by后distinct,还是先distinct后group by呢?
先说结论:先group by后distinct。
以下是在HIVE中的验证:
1)建表:其中xxx替换为本地目录名
create external table tmp_tb(id int,content int) row format delimitedfields terminated by ','stored as textfilelocation '/tmp/xxx';
2)从tmp_tb文件中导入数据
load datalocal inpath '/home/xxx/tmp_tb'overwrite into table tmp_tb;tmp_tb内容:
1,5
2,6
2,5
2,5
3,6
3)仅有group by时:
select id, count(content)from tmp_tbgroup by id;结果如下:
1 1
2 3
3 1
4)同时有group by和distinct时:
select id, count(distinct content)from tmp_tbgroup by id;
结果如下:
1 1
2 2
3 1
可见,同时有group by和distinct时,显然是先group by 后distinct。如果是先distinct,后group by,则结果应该只有两条记录,因为content只有5和6两种数值。
0 0
- HIVE点滴:group by和distinct语句的执行顺序
- hive高阶1--sql和hive语句执行顺序、explain查看执行计划、group by生成MR
- Mysql的distinct语句和group by,order by
- Group By 和 Having, Where ,Order by语句的执行顺序
- Group By 和 Having, Where ,Order by语句的执行顺序(转载)
- Group By 和 Having, Where ,Order by语句的执行顺序
- Group By 和 Having, Where ,Order by语句的执行顺序:
- Group By和Having,Where,Order by语句的执行顺序
- mysql ORDER BY,GROUP BY 和DISTINCT原理 及执行顺序
- 当一个查询语句同时出现了where,group by,having,order by的时候,执行顺序和编写顺序
- 当一个查询语句同时出现了where,group by,having,order by的时候,执行顺序和编写顺序
- 当一个查询语句同时出现了where,group by,having,order by的时候,执行顺序和编写顺序
- Group By 和 Having, Where ,Order by的执行顺序
- DISTINCT和GROUP BY
- distinct和group by
- distinct和group by
- HIVE group by 和count(distinct)进行对比
- hive的strict模式;where,group by,having,order by同时使用的执行顺序
- 哪些设计模式是降低资源使用率:----腾讯2016研发工程师笔试题(一)
- C/C++遍历Lua中的table
- ScrollView与Listview滑动冲突解决
- POJ-1953-World Cup Noise
- 前言介绍
- HIVE点滴:group by和distinct语句的执行顺序
- java 集合类Array、List、Map区别和联系
- BZOJ3155 Preprefix sum
- 给input文本框添加灰色提示文字
- select()
- 文章标题
- org.eclipse.jdt.core.prefs
- 欢迎使用CSDN-markdown编辑器
- HTML5基础学习笔记(五)