hive初試

1:搭建hadoop和hive,mysql的環境,過程截圖。

 

2:利用上節課的數據,建表並導入數據。

3:最熱門的查詢詞排行 top10
4:用戶查詢排行 top10
5:搜索結果排名第1,但是點擊次序排在第2的數據有多少?

 

2:利用上節課的數據,建表並導入數據。

數據格式說明:
訪問時間\t用戶ID\t[查詢詞]\t該URL在返回結果中的排名\t用戶點擊的順序號\t用戶點擊的URL
其中,用戶ID是根據用戶使用瀏覽器訪問搜索引擎時的Cookie信息自動賦值,即同一次使用瀏覽器輸入的不同查詢對應同一個用戶ID。

CREATE EXTERNAL TABLE sg_table(
  last_update string,
  col_a string,
  col_b string,
  col_c string,
  col_d string,
  col_e string,
  col_f string,
  col_g string,
  col_h string,
  col_i string,
  col_j string)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
location '/hadoop/dw/sogoutest';
hadoop put sogout.txt /hadoop/dw/sogoutest

 

3:最熱門的查詢詞排行 top10

select col_b ,count(col_b) as top10 from sg_table group by col_b  order by top10  desc limit 10 ;


4:用戶查詢排行 top10

select col_a ,count(col_a) as top10 from sg_table group by col_a  order by top10  desc limit 10 ;


5:搜索結果排名第1,但是點擊次序排在第2的數據有多少?

select col_b , count(col_b) as top1  from sg_table where col_i=2 group by col_b order by top1 desc limit 1;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章