hive sql解决关联条件中不等值连接问题及累计值的计算
来源:互联网 发布:淘宝贷款怎么回事 编辑:程序博客网 时间:2024/04/27 08:51
工作中写的sql,本次的sql可以拓展出一些新内容,留下笔记
with a as (select interface,case when action is NUll then 'null' else action end as action, request_time*1000 as request_time ,count(request_time) as pvfrom xx_xxwhere ds >= %YYYYMMDD% || '00' and ds <= %YYYYMMDD% || '23'group by interface,action,request_time * 1000),b as ( select a1.interface ,a1.action,a1.request_time,a1.pv ,sum(case when a1.request_time>= a2.request_time then a2.pv end) as sum_cnt --解决hive sql关联条件中不等值连接问题 from a a1 join a a2on a1.interface = a2.interface and a1.action = a2.action group by a1.interface ,a1.action,a1.request_time,a1.pv ),c as (select b.interface ,b.action ,case when b.sum_cnt / t.total_pv >=0.90 then b.request_time end as geo_time_90 ,case when b.sum_cnt / t.total_pv >=0.95 then b.request_time end as geo_time_95 ,case when b.sum_cnt / t.total_pv >=0.99 then b.request_time end as geo_time_99from bjoin (select interface,action,sum(pv) as total_pvfrom a group by interface ,action)t on b.interface = t.interfaceand b.action = t.action)select c.interface,c.action,min(geo_time_90) as geo_time_90,min(geo_time_95) as geo_time_95,min(geo_time_99) as geo_time_99from cgroup by c.interface,c.action
阅读全文
0 0
- hive sql解决关联条件中不等值连接问题及累计值的计算
- hive中间接实现不等值连接
- hive中间接实现不等值连接<转>
- where条件中等值连接使用双竖杠影响SQL性能
- Hive 中 Map Join 的适用场景:非等值连接
- hive 非等值连接sql写法
- 非等值连接中,连接条件与where条件的区别
- hive 不等值
- hive 非等值连接sql写法-2<转>
- Hive 中 Map Join 的适用场景:非等值连接<转>
- Spark-sql 连接hive中遇到的问题
- 数据库外连接,自然连接,内连接,条件连接,等值连接关系及详解
- 解决java 连接不上 sql server 2000 的问题
- 关于解决hibernate左连接关联查询不执行的问题
- 4.解决多表连接中(左连和等值)因添加新的报表导致查询结果有问题的方法
- 数据库中左连接|右连接|等值连接的使用
- linq中怎么实现多条件关联的左连接???
- sql中数据相减求当天累计值
- Elasticsearch的distinct项查询(去重查询)
- 小测验:解密文件——题解
- 617. Merge Two Binary Trees
- SQL大全(二)
- Linux添加服务到开机自动启动
- hive sql解决关联条件中不等值连接问题及累计值的计算
- 原码、反码、补码
- 问题 bug
- 流水并行编程
- 剑指Offer-求1+2+3+...+n
- Linux-信号
- 加载背景图、播放音乐
- java4——Scanner,final的用法
- 验证码机制与实现