记hive select distinct 多列 误区一则

当select distinct a,b,c时,只会对a、b、c都起作用,无法达到只顾虑多余的a列;

根据hive官方网站说明:当有表

a  b

10  1

10  2

10  3

此时select a,b from test group by a是无法工作的,因为hive不知道你是要取第一行的b还是取最小的b,所以选择权交给用户。

可以这样达到效果:select a ,min(b) b from test group by a

MySQL等其他数据库默认是支持的,并且默认是取第一行

posted on 2014-07-22 22:54  a_badegg  阅读(1821)  评论(0编辑  收藏  举报

导航