• HUE-hive常用查询语句整理


    通过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('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).+'
  • 相关阅读:
    常用dos命令
    最新Java校招面试题及答案
    计算机的基本组成及其工作原理
    java中的三大排序算法
    JSP九大内置对象的作用和用法总结
    java代码实现二叉树的遍历
    转发和重定向的区别
    解决中文乱码问题大全
    创建线程的三种方式对比
    Excel 不同文件、sheet 关联引用(vlookup函数)
  • 原文地址:https://www.cnblogs.com/smuxiaolei/p/10847391.html
Copyright © 2020-2023  润新知