經過hue進行數據導入: 1,create table demo_id(`id` string) row format serde 'org.apache.hadoop.hive.serde2.OpenCSVSerde' 2, load data inpath '/user/demo.csv' into table demo_id #sql數據篩選 create table `table_name` as select a.id,a.name,a.time from `a_name` a where a.type = 'A' and a.year = '2018' and A.month IN('01','02', '03') and a.idstr regxp '^\\$\\_[0-9][0-9]\\0.+' #sql數據聯表,左外鏈接查詢 create table `table_name` as select b.id, b.name, b.month from `a_name` a JOIN `b_name` b on a.id =b.id where b.idstr regxp '^\\$\\_(?!01).+' #sql數據查詢 group by create table `table_name` as select a.id,a.name,min(a.month) from `a_name` a where a.str = '你好' and a.m > '05' group by a.str,a.id #sql數據排序 order by,將查詢結果按照a字段分組(partition),而後組內按照b字段排序,row_number() 用於標記順序 create table `table_name` as select * from (select *,row_number() over(partition by t.deviceid order by t.time DESC) as RNO from `table_name_A` t) as TEMP where TEMP.RNO<7 #sql數據切分字段,並排序 selcet b.id, substr(b.str,3,2),count(b.name) as count from `table_name` b group by b.id #統計人數,按照用戶去重 select count(distinct(a.id)) from `table_name` a #根據數字排序 order by cast(a.number as INT) #正則匹配多條件 where a.str regexp '^\\$\\_01\\_(?!0\\01|0\\_00|0\\_11).+'