hive sql学习

Posted 九友

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hive sql学习相关的知识,希望对你有一定的参考价值。

-- 转化占比  tmk约课和总的约课在最近两个月的转化人数
select
on_where,
count(distinct T.fk_student) as subscribe_num_1,
count(distinct if(is_attend=1,fk_student,null)) attend_num_1,
count(distinct if(is_attend=1 and course_start_time<pay_end_time,stu_id,null)) zjk_num_1

from(
select *
    from (
    
    select fk_student,course_start_time,on_where,
           if(goto_class_time!=‘0‘ and is_replay!=1,1,null) is_attend
    from dwddb.dwd_mkt_experience_class_detail
    where course_start_time>="2019-08-30" AND course_start_time<=current_date() and
    status = 1 and dp = ‘active‘ and on_where =2) as b
    
    left join
    (select stu_id,pay_end_time
        from dwddb.dwd_trd_sales_stu_all_v1
        where pay_end_time>="2019-08-30" and pay_end_time <= current_date() and
        course_type_first_id = 1
        and  return_type = 1
        and stu_type_v1 !=6
        and dt=regexp_replace(date_sub(current_date(),1),"-","")
        ) a 
        
        on a.stu_id = b.fk_student
        
    where pay_end_time BETWEEN course_start_time and DATE_add(course_start_time, 15)
) T
group by on_where

  

以上是关于hive sql学习的主要内容,如果未能解决你的问题,请参考以下文章

Hive学习之路 Hive SQL练习之影评案例

Hive学习之路 Hive SQL之数据类型和存储格式

Hive入门小结

Spark基础学习笔记27:Spark SQL数据源 - Hive表

hive sql学习

大数据学习——hive的sql练习