hive之查询

1.聚合处理,在组里面,每个用户购买的订单要大于1
$hive>select cid count() max(price) from orders group by cid having count()>1;
2.使用hive实现wordcount
$hive>select split(line,' ') from doc; //按照空格来进行切割
$hive>select t.word,count(t) from ((select explode(splite(line,' ')) as word from doc) as t) group by t.word order by count() desc limit 2; //对选中的数据进行炸裂操作
$hive>select t.word,count(
) c from ((select explode(split(line,' ')) as word from doc) as t) group by t.word group by t.word order by c desc limit 2;
//将单词统计的结果套到一个表中去
create table stats as (select t.word,count(*) c from ((select explode(split(line,' ')) as word from doc) as t) group by t.word group by t.word order by c desc limit 2);

//支持事务:
$hive>create table tx(id int,name string ,age int)  clustered by(id) into 3 buckets  row format delimited fields terminated by ',' stored as orc tblproperties('transactional'='true');
原文地址:https://www.cnblogs.com/stone-learning/p/9280951.html