首页 > 其他 > 详细

HUE-hive常用查询语句整理

时间:2019-05-11 11:12:23      阅读:513      评论:0      收藏:0      [点我收藏+]
通过hue进行数据导入:
1create 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(0102, 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).+

 

HUE-hive常用查询语句整理

原文:https://www.cnblogs.com/smuxiaolei/p/10847391.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!