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);code

//支持事務:
$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');
相關文章
相關標籤/搜索