懵懂的菜鸟

Stay hungry,Stay foolish.

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

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).+'
复制代码

 

posted on   懵懂的菜鸟  阅读(5312)  评论(0编辑  收藏  举报

编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
历史上的今天:
2018-05-11 spass按位置编码,进行排序题处理与分析
点击右上角即可分享
微信分享提示