开发者社区 > 大数据与机器学习 > 大数据计算 MaxCompute > 正文

maxcompute这两条语句都是取最大时间和最小时间,压缩数据量相差很大怎么解决?

maxcompute这两条语句都是取最大时间和最小时间,压缩数据量相差很大怎么解决? select app_name,corp_id,user_id,event_code, max(last_time)last_time,min(first_time)first_time, sum(cnt)cnt from ( select app_name,corp_id,user_id,event_code,last_time,first_time,cnt from dwd_user_burypoint_record_df_tmp union all select app_name,corp_id,user_id,event_code,last_time,first_time,cnt from dwd_user_burypoint_record_df where ds=to_char(dateadd(to_date(${bdp.system.bizdate},'yyyymmdd'),'-1','dd'),'yyyymmdd') --and corp_id in (select corp_id from dwd_user_burypoint_record_df_tmp) ) as c group by app_name,corp_id,user_id,event_code

select
nvl(a.app_name , b.app_name ) app_name ,nvl(a.corp_id , b.corp_id ) corp_id ,nvl(a.user_id , b.user_id ) user_id ,nvl(a.event_code , b.event_code ) event_code ,greatest(nvl(a.last_time , b.last_time),nvl(b.last_time , a.last_time)) last_time ,least (nvl(a.first_time , b.first_time),nvl(b.first_time , a.first_time)) first_time ,nvl(a.cnt , 0 ) + nvl(b.cnt , 0 ) cnt from (select app_name,corp_id,user_id,event_code,last_time,first_time,cnt from dwd_user_burypoint_record_df_tmp ) a full join (select app_name,corp_id,user_id,event_code,last_time,first_time,cnt from dwd_user_burypoint_record_df where ds=to_char(dateadd(to_date(${bdp.system.bizdate},'yyyymmdd'),'-1','dd'),'yyyymmdd') ) b on nvl(a.app_name,'') =nvl(b.app_name,'')
and nvl(a.corp_id ,'') =nvl(b.corp_id ,'')
and nvl(a.user_id,'')=nvl(b.user_id,'') and nvl(a.event_code,'') =nvl(b.event_code ,'') zorder by app_name,corp_id,user_id,event_code

展开
收起
爱喝咖啡嘿 2022-12-21 14:15:49 274 0
1 条回答
写回答
取消 提交回答
  • 两个代码,一个没有走关联,一个走了关联,数据量不同很正常

    2022-12-22 23:15:54
    赞同 展开评论 打赏

MaxCompute(原ODPS)是一项面向分析的大数据计算服务,它以Serverless架构提供快速、全托管的在线数据仓库服务,消除传统数据平台在资源扩展性和弹性方面的限制,最小化用户运维投入,使您经济并高效的分析处理海量数据。

相关产品

  • 云原生大数据计算服务 MaxCompute
  • 热门讨论

    热门文章

    相关电子书

    更多
    Data+AI时代大数据平台应该如何建设 立即下载
    大数据AI一体化的解读 立即下载
    极氪大数据 Serverless 应用实践 立即下载